UNPKG

fastchar-dom-plugin

Version:

Chrome插件,用于操作HTML的DOM

1 lines 6.39 kB
(()=>{var t={760:(t,n,e)=>{var o;o=function(t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.FastConstant=void 0,function(t){var n=function(){function t(){}return t.buildUDID=function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var e=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==n?e:3&e|8).toString(16)}))},t}();t.FastHelper=n;var e=function(){function t(){}return t.debug=!1,t.PLUGIN_VERSION="2.1.5",t.PLUGIN_DOWNLOAD_URL="https://www.fastchar.com/fastchar-dom-plugin.zip",t.USE_RUNTIME_CONNECT=!0,t.DOM_TAG_NAME="fastchar-dom-plugin",t.DOM_DATA_NAME="fastchar-dom-data",t.DOM_DATA_RECEIVE="fastchar-dom-data-receive",t.DOM_DATA_INVOKE_COUNT="fastchar-dom-data-invoke-count",t.DOM_DATA_CALLBACK_TOTAL="fastchar-dom-data-callback-total",t.DOM_DATA_CALLBACK_ALWAYS="fastchar-dom-data-callback-always",t.DOM_DATA_CALLBACK_TAG_NAME="fastchar-dom-callback",t.DOME_DATA_ERROR="fastchar-dom-error",t.DOM_PLUGIN="fastchar-dom-plugin",t.DOM_PLUGIN_VERSION="fastchar-dom-plugin-version",t.DOM_INVOKE_TIMEOUT=15e3,t.DOM_CONTENT_IDLE_DURATION=100,t.DOM_CONTENT_TIMEOUT=3e3,t.DOM_BACKGROUND_IDLE_DURATION=100,t}();t.FastDOM=e;var o=function(){function t(){}return t.ON_REGISTER_CONNECT="OnRegisterConnect",t.ON_INVOKE_METHOD="OnInvokeMethod",t.ON_RETURN_METHOD="OnReturnMethod",t.ON_WATCH_MESSAGE="OnWatchMessage",t.ON_IDLE="OnIdle",t}();t.FastDOMEvents=o;var a=function(){function t(){}return t.HTTP_RESPONSE_LISTENER="HTTP_RESPONSE_LISTENER",t}();t.WindowMessageEvents=a}(n.FastConstant||(n.FastConstant={}))}.apply(n,[e,n]),void 0===o||(t.exports=o)},735:(t,n,e)=>{var o,a;o=[e,n,e(760)],a=function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.FastBackgroundScript=void 0,function(t){var n=function(){function n(){chrome.action.onClicked.addListener((function(){chrome.tabs.create({url:"https://www.fastchar.com/doc-dom-plugin/"},(function(){}))})),chrome.runtime.onMessage.addListener(t.Core.notifyEvent),e.FastConstant.FastDOM.USE_RUNTIME_CONNECT?n.startConnectListener():n.startIdle()}return n.startIdle=function(){setTimeout((function(){t.Core.clearConnectTimeout(),t.Core.startIdle()}),e.FastConstant.FastDOM.DOM_BACKGROUND_IDLE_DURATION)},n.startConnectListener=function(){chrome.runtime.onConnect.addListener((function(o){0===o.name.indexOf("FastCharDOM")&&(o.onMessage.addListener((function(n,e){t.Core.notifyEvent(n,e,(function(){}))})),o.onDisconnect.addListener((function(o){if(e.FastConstant.FastDOM.debug){var a=n.getConnectInfo(o.name);console.debug("[BackgroundScript]已断开连接!",a,new Date)}delete t.Core.connectInfo[o.name]})))}))},n.getConnectInfo=function(n){return t.Core.connectInfo.hasOwnProperty(n)||(t.Core.connectInfo[n]=new o),t.Core.connectInfo[n]},n.getAllConnectInfo=function(){var n=[];for(var e in t.Core.connectInfo){var o=t.Core.connectInfo[e];o.isTimeout()||n.push(o)}return n},n.getMatchUrlConnect=function(n){var e=[];for(var o in t.Core.connectInfo){var a=t.Core.connectInfo[o];a.isTimeout()||(n.url?a.connectMsg.url.toString().trim().indexOf(n.url.trim())>=0&&e.push(a):e.push(a))}return e},n.notifyEvent=function(o,a,r){try{if(o&&o.event){if(o.event===e.FastConstant.FastDOMEvents.ON_INVOKE_METHOD){if(e.FastConstant.FastDOM.debug&&console.debug("[BackgroundScript]"+e.FastConstant.FastDOMEvents.ON_INVOKE_METHOD,o,new Date),o.method&&"getCookie"===o.method)return chrome.cookies.getAll(o.params[0],(function(n){var a=t.Core.copy(o);for(var r in a.success=!0,a.data=n,a.invokeCount=1,a.catchCount=1,o)a[r]=o[r];a.message="获取成功!",a.event=e.FastConstant.FastDOMEvents.ON_RETURN_METHOD,t.Core.getConnectInfo(a.contentName).addNewMessage(a)})),void r(!0);for(var s=t.Core.getMatchUrlConnect(o),c=0;c<s.length;c++){var i=s[c];(u=t.Core.copy(o)).catchCount=s.length,u.invokeCount=s.length,u.fromContentName=i.connectMsg.contentName,u.msgId=e.FastConstant.FastHelper.buildUDID(),i.addNewMessage(u)}return 0===s.length&&((u=t.Core.copy(o)).catchCount=1,u.invokeCount=0,u.message="",u.event=e.FastConstant.FastDOMEvents.ON_RETURN_METHOD,u.data=[],t.Core.getConnectInfo(u.contentName).addNewMessage(u)),void r(!0)}if(o.event===e.FastConstant.FastDOMEvents.ON_RETURN_METHOD){if(e.FastConstant.FastDOM.debug&&console.debug("[BackgroundScript]"+e.FastConstant.FastDOMEvents.ON_RETURN_METHOD,o,new Date),o.contentName){var u=t.Core.copy(o);t.Core.getConnectInfo(u.contentName).addNewMessage(u)}else for(var f=t.Core.getAllConnectInfo(),C=0,O=f;C<O.length;C++){var d=O[C];(u=t.Core.copy(o)).contentName=d.connectMsg.contentName,d.addNewMessage(u)}return void r(!0)}if(o.event===e.FastConstant.FastDOMEvents.ON_REGISTER_CONNECT||o.event===e.FastConstant.FastDOMEvents.ON_IDLE)return(M=n.getConnectInfo(o.contentName)).connectMsg=o,M.connectPort=a,M.sendAllNewMessage(),void r(!0);if(o.event===e.FastConstant.FastDOMEvents.ON_WATCH_MESSAGE){var M;(M=n.getConnectInfo(o.contentName)).connectMsg=o;var g=M.getNewMessage();return g||(g={}),r(g),void(e.FastConstant.FastDOM.debug&&console.debug("[BackgroundScript]"+e.FastConstant.FastDOMEvents.ON_WATCH_MESSAGE,M,new Date))}}}catch(t){}r(!1)},n.clearConnectTimeout=function(){var n=[];for(var o in t.Core.connectInfo){var a=t.Core.connectInfo[o];a.isTimeout()&&(e.FastConstant.FastDOM.debug&&console.debug("[BackgroundScript]超时连接!",a,new Date),n.push(o))}for(var r=0,s=n;r<s.length;r++){var c=s[r];delete t.Core.connectInfo[c]}},n.copy=function(t){var n={};for(var e in t)n[e]=t[e];return n},n.connectInfo={},n}();t.Core=n;var o=function(){function t(){this.newMessage=[],this.connectMsg={}}return t.prototype.getNewMessage=function(){return this.newMessage.shift()},t.prototype.sendAllNewMessage=function(){if(this.connectPort)for(var t=0,n=this.newMessage;t<n.length;t++){var e=n[t];this.connectPort.postMessage(e)}},t.prototype.addNewMessage=function(t){this.connectPort?this.connectPort.postMessage(t):this.newMessage.push(t)},t.prototype.isTimeout=function(){if(this.connectPort)return!1;var t=(new Date).getTime();return Math.abs(this.connectMsg.timestamp-t)>=e.FastConstant.FastDOM.DOM_CONTENT_TIMEOUT},t}();for(var a in t.ConnectPage=o,t)t[a]()}(n.FastBackgroundScript||(n.FastBackgroundScript={}))}.apply(n,o),void 0===a||(t.exports=a)}},n={};!function e(o){var a=n[o];if(void 0!==a)return a.exports;var r=n[o]={exports:{}};return t[o](r,r.exports,e),r.exports}(735)})();