fastchar-dom-plugin
Version:
Chrome插件,用于操作HTML的DOM
1 lines • 9.62 kB
JavaScript
(()=>{var t={760:(t,e,n)=>{var o;o=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FastConstant=void 0,function(t){var e=function(){function t(){}return t.buildUDID=function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)}))},t}();t.FastHelper=e;var n=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=n;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}(e.FastConstant||(e.FastConstant={}))}.apply(e,[n,e]),void 0===o||(t.exports=o)},923:(t,e,n)=>{var o,a;o=[n,e,n(760)],a=function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FastPlugin=void 0,function(t){var e=function(){function e(){}return e.isFunction=function(t){return null!=t&&!!t&&"function"==typeof t},e.checkPluginVersion=function(){if(t.Core.newPluginVersion()){var o=new s("showConfirm",[],["系统提醒","您当前的FastCharDOM插件版本过低!最新版本为:"+n.FastConstant.FastDOM.PLUGIN_VERSION+" ,建议您立即更新!","red",["立即下载","取消"]],"self");o.type="dialog",o.timeout=!1,e.invokeMethod(o,(function(t){if(t.success&&t.data&&t.data.length>0){var e=t.data[0];e.button&&"ok"===e.button&&(window.location.href=n.FastConstant.FastDOM.PLUGIN_DOWNLOAD_URL)}}))}},e.newPluginVersion=function(){var t=document.getElementsByTagName("html")[0];if(t){var e=t.getAttribute(n.FastConstant.FastDOM.DOM_PLUGIN_VERSION),o=parseFloat(e.replace(".",""));return parseFloat(n.FastConstant.FastDOM.PLUGIN_VERSION.replace(".",""))>o}return!1},e.setInvokeTimeout=function(t){n.FastConstant.FastDOM.DOM_INVOKE_TIMEOUT=t},e.createCallbackPluginEl=function(t){var e=document.createElement(n.FastConstant.FastDOM.DOM_TAG_NAME);return t&&e.setAttribute("id",t),e.setAttribute("style","display:none;"),document.getElementsByTagName("html")[0].appendChild(e),e},e.invokeMethod=function(o,a){"complete"===document.readyState?function(){if(t.Core.isFunction(a)){var i=document.getElementsByTagName("html")[0],r="执行失败,未检测到浏览器安装FastChar-DOM-Plugin插件!请您先安装插件!或者建议您在页面加载完成后再调用功能。";if(!i)return console.error(r),void a(new l(!1,r,-9,[]));if("true"!==i.getAttribute(n.FastConstant.FastDOM.DOM_PLUGIN))return console.error(r),void a(new l(!1,r,-9,[]));var s=n.FastConstant.FastHelper.buildUDID();o.callbackId=s;var c=e.createCallbackPluginEl(s);c?(c.setAttribute(n.FastConstant.FastDOM.DOM_DATA_NAME,JSON.stringify(o)),e.CallBackFunctionStore[s]=a,c.addEventListener(s,(function(t){e.checkCallbackEl(t.type,!1,!0),e.startCallbackTimeout(t.type)})),c.addEventListener(s+"Error",(function(t){e.callbackError(t.type.replace("Error",""))})),i.dispatchEvent(new Event(n.FastConstant.FastDOMEvents.ON_INVOKE_METHOD))&&o.timeout&&e.startCallbackTimeout(s)):a(new l(!1,"执行失败!回调函数标签构建失败!",-8,[]))}else console.error(new l(!1,"回调函数参数错误!",-8,[]))}():setTimeout((function(){e.invokeMethod(o,a)}),500)},e.startCallbackTimeout=function(o){e.clearCallbackTimeout(o),e.CallBackTimeoutStore[o]=setTimeout((function(){t.Core.checkCallbackEl(o,!0,!0)}),n.FastConstant.FastDOM.DOM_INVOKE_TIMEOUT)},e.clearCallbackTimeout=function(t){try{e.CallBackTimeoutStore[t]&&clearTimeout(e.CallBackTimeoutStore[t])}finally{delete e.CallBackTimeoutStore[t]}},e.checkCallbackEl=function(t,o,a){try{var i=document.getElementById(t);if(!i)return;var r=parseInt(i.getAttribute(n.FastConstant.FastDOM.DOM_DATA_INVOKE_COUNT));isNaN(r)&&(r=0);var s=parseInt(i.getAttribute(n.FastConstant.FastDOM.DOM_DATA_CALLBACK_TOTAL));isNaN(s)&&(s=0);var c=e.CallBackFunctionStore[t];if(!c)return;var u=new l(!0,"执行成功!",0,[]);u.data=[],u.invoke=r;var d=i.getAttribute(n.FastConstant.FastDOM.DOM_DATA_NAME);if(d)try{u.method=JSON.parse(d)}catch(t){}var f=s===i.childNodes.length,v="true"===i.getAttribute(n.FastConstant.FastDOM.DOM_DATA_CALLBACK_ALWAYS);if(v&&(f=!0),o&&!v&&(f=!0,u.message="功能执行超时!"),0!==r||v||(u.message=o?"功能执行超时!":"未匹配到有效网站!",u.success=!1,u.code=o?-2:-1),f){if(v){if(i.childNodes.length>0){var h=i.childNodes[0];try{var M=JSON.parse(h.innerText);u.data.push.apply(u.data,M.data)}catch(t){}finally{i.removeChild(h)}}}else for(var O=0;O<i.childNodes.length;O++)try{h=i.childNodes[O],M=JSON.parse(h.innerText),u.data.push.apply(u.data,M.data)}catch(t){}c(u),n.FastConstant.FastDOM.debug||i.parentNode&&a&&i.parentNode.removeChild(i),v||delete e.CallBackFunctionStore[t]}}finally{e.clearCallbackTimeout(t)}},e.callbackError=function(t){try{var o=document.getElementById(t);if(!o)return;var a=e.CallBackFunctionStore[t];if(!a)return;var i=new l(!1,o.getAttribute(n.FastConstant.FastDOM.DOME_DATA_ERROR),-8,[]);i.invoke=0,a(i),delete e.CallBackFunctionStore[t]}finally{e.clearCallbackTimeout(t)}},e.CallBackTimeoutStore={},e.CallBackFunctionStore={},e}();t.Core=e;var o=function(){function t(){}return t.getHtml=function(t,n){e.invokeMethod(new s("prop",[t],["outerHTML"],void 0),n)},t.getHtmlFromUrl=function(t,n,o){e.invokeMethod(new s("prop",[n],["outerHTML"],t),o)},t.getText=function(t,n){e.invokeMethod(new s("text",[t],[],void 0),n)},t.getTextFromUrl=function(t,n,o){e.invokeMethod(new s("text",[n],[],t),o)},t.setValue=function(t,n,o){e.invokeMethod(new s("val",[t],[n],void 0),o)},t.setValueFromUrl=function(t,n,o,a){e.invokeMethod(new s("val",[n],[o],t),a)},t.getValue=function(t,n){e.invokeMethod(new s("val",[t],[],void 0),n)},t.getValueFromUrl=function(t,n,o){e.invokeMethod(new s("val",[n],[],t),o)},t.click=function(t,n){e.invokeMethod(new s("click",[t],[],void 0),n)},t.clickFromUrl=function(t,n,o){e.invokeMethod(new s("click",[n],[],t),o)},t.fireEvent=function(t,n,o){var a=new s("fireEvent",[t],[n],void 0);a.type="js",e.invokeMethod(a,o)},t.fireEventFromUrl=function(t,n,o,a){var i=new s("fireEvent",[n],[o],t);i.type="js",e.invokeMethod(i,a)},t.invokeFromUrl=function(t,n,o,a,i){e.invokeMethod(new s(n,[a],o,t),i)},t.invoke=function(t,n,o,a){e.invokeMethod(new s(t,[o],n,void 0),a)},t.invokeMethod=function(t,n){e.invokeMethod(t,n)},t.exist=function(t,n){e.invokeMethod(new s("exist",[t],[],void 0),n)},t.existFromUrl=function(t,n,o){e.invokeMethod(new s("exist",[n],[],t),o)},t}();t.Element=o;var a=function(){function t(){}return t.reloadFromUrl=function(t,n){e.invokeMethod(new s("reload",[],[],t),n)},t.hasTabFomUrl=function(t,n){e.invokeMethod(new s("attr",["html"],["fastchar-dom-plugin"],t),(function(t){n(t.success)}))},t.getCookie=function(t,n){var o=new s("getCookie",[],[t],"*");o.type="js",e.invokeMethod(o,n)},t}();t.Location=a;var i=function(){function t(){}return t.addResponseListener=function(t,o){var a=t+n.FastConstant.WindowMessageEvents.HTTP_RESPONSE_LISTENER,i=e.createCallbackPluginEl(a);i?(i.setAttribute(n.FastConstant.FastDOM.DOM_DATA_CALLBACK_ALWAYS,"true"),e.CallBackFunctionStore[a]=o,i.addEventListener(a,(function(t){e.checkCallbackEl(t.type,!1,!1),e.startCallbackTimeout(t.type)}))):o(new l(!1,"添加失败!回调函数标签构建失败!",-8,[]))},t}();t.Http=i;var r=function(){function n(){}return n.showLoading=function(e,n){t.Dialog.showLoadingToUrl("",e,n)},n.showLoadingToUrl=function(t,n,o){var a=new s("showLoading",[],[n],t);a.type="dialog",e.invokeMethod(a,o)},n.hideLoading=function(e){t.Dialog.hideLoadingToUrl("",e)},n.hideLoadingToUrl=function(t,n){var o=new s("hideLoading",[],[],t);o.type="dialog",e.invokeMethod(o,n)},n.showAlert=function(e,n,o){t.Dialog.showAlertToUrl("",e,n,o)},n.showAlertToUrl=function(t,n,o,a){var i=new s("showAlert",[],[n,o],t);i.type="dialog",i.timeout=!1,e.invokeMethod(i,a)},n.showConfirm=function(e,n,o){t.Dialog.showConfirmToUrl("",e,n,o)},n.showConfirmToUrl=function(t,n,o,a){var i=new s("showConfirm",[],[n,o],t);i.type="dialog",i.timeout=!1,e.invokeMethod(i,a)},n.showAlertTip=function(e,n,o,a){t.Dialog.showAlertToUrl("",e,n,a)},n.showAlertTipToUrl=function(t,n,o,a,i){var r=new s("showAlertTip",[],[n,o,a],t);r.type="dialog",e.invokeMethod(r,i)},n}();t.Dialog=r;var l=function(t,e,n,o){this.success=t,this.message=e,this.code=n,this.data=o};t.CallbackInfo=l;var s=function(t,e,n,o){this.type="jquery",this.timeout=!0,this.method=t,this.selectors=e,this.params=n,this.url=o};t.MethodInfo=s;for(var c in t.CookieInfo=function(){},t)t[c]();window.FastPlugin=t}(e.FastPlugin||(e.FastPlugin={}))}.apply(e,o),void 0===a||(t.exports=a)}},e={};!function n(o){var a=e[o];if(void 0!==a)return a.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}(923)})();