Deploying to gh-pages from @ fishjar/kiss-translator@df950a1bd2 🚀

This commit is contained in:
fishjar
2023-08-28 17:23:01 +00:00
parent c2b9df666e
commit a48656ce2a

View File

@@ -28288,14 +28288,14 @@ window.dispatchEvent(new CustomEvent(EVENT_KISS,{detail:{action:MSG_TRANS_CURRUL
;// CONCATENATED MODULE: ./src/userscript.js ;// CONCATENATED MODULE: ./src/userscript.js
/** /**
* 入口函数 * 入口函数
*/var init=/*#__PURE__*/function(){var _ref=asyncToGenerator_asyncToGenerator(/*#__PURE__*/regeneratorRuntime_regeneratorRuntime().mark(function _callee(){var ping,href,setting,rules,rule,translator,fab,$action,shadowContainer,emotionRoot,shadowRootElement,cache;return regeneratorRuntime_regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(document.location.href.includes("http://localhost:3000/options.html")||document.location.href.includes("https://kiss-translator.rayjar.com/options")||document.location.href.includes("https://fishjar.github.io/kiss-translator/options.html"))){_context.next=5;break;}// unsafeWindow.GM = GM; */var init=/*#__PURE__*/function(){var _ref=asyncToGenerator_asyncToGenerator(/*#__PURE__*/regeneratorRuntime_regeneratorRuntime().mark(function _callee(){var ping,script,href,setting,rules,rule,translator,fab,$action,shadowContainer,emotionRoot,shadowRootElement,cache;return regeneratorRuntime_regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(document.location.href.includes("http://localhost:3000/options.html")||document.location.href.includes("https://kiss-translator.rayjar.com/options")||document.location.href.includes("https://fishjar.github.io/kiss-translator/options.html"))){_context.next=7;break;}// unsafeWindow.GM = GM;
// unsafeWindow.APP_NAME = process.env.REACT_APP_NAME; // unsafeWindow.APP_NAME = process.env.REACT_APP_NAME;
ping=btoa(Math.random()).slice(3,11);window.addEventListener(ping,handlePing);window.eval("(".concat(injectScript,")(\"").concat(ping,"\")"));// eslint-disable-line ping=btoa(Math.random()).slice(3,11);window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line
return _context.abrupt("return");case 5:// 翻译页面 script=document.createElement("script");script.textContent="(".concat(injectScript,")(\"").concat(ping,"\")");if(document.head){document.head.append(script);}return _context.abrupt("return");case 7:// 翻译页面
href=isIframe?document.referrer:document.location.href;_context.next=8;return libs_getSetting();case 8:setting=_context.sent;_context.next=11;return libs_getRules();case 11:rules=_context.sent;_context.next=14;return matchRule(rules,href,setting);case 14:rule=_context.sent;translator=new Translator(rule,setting);if(!isIframe){_context.next=19;break;}// iframe href=isIframe?document.referrer:document.location.href;_context.next=10;return libs_getSetting();case 10:setting=_context.sent;_context.next=13;return libs_getRules();case 13:rules=_context.sent;_context.next=16;return matchRule(rules,href,setting);case 16:rule=_context.sent;translator=new Translator(rule,setting);if(!isIframe){_context.next=21;break;}// iframe
window.addEventListener("message",function(e){var _e$data;var action=e===null||e===void 0?void 0:(_e$data=e.data)===null||_e$data===void 0?void 0:_e$data.action;switch(action){case MSG_TRANS_TOGGLE:translator.toggle();break;case MSG_TRANS_PUTRULE:translator.updateRule(e.data.args||{});break;default:}});return _context.abrupt("return");case 19:_context.next=21;return getFab();case 21:fab=_context.sent;$action=document.createElement("div");$action.setAttribute("id","kiss-translator");document.body.parentElement.appendChild($action);shadowContainer=$action.attachShadow({mode:"closed"});emotionRoot=document.createElement("style");shadowRootElement=document.createElement("div");shadowContainer.appendChild(emotionRoot);shadowContainer.appendChild(shadowRootElement);cache=(0,emotion_cache_browser_esm/* default */.Z)({key:"css",prepend:true,container:emotionRoot});client.createRoot(shadowRootElement).render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(emotion_element_c39617d8_browser_esm.C,{value:cache,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Action,{translator:translator,fab:fab})})}));// 注册菜单 window.addEventListener("message",function(e){var _e$data;var action=e===null||e===void 0?void 0:(_e$data=e.data)===null||_e$data===void 0?void 0:_e$data.action;switch(action){case MSG_TRANS_TOGGLE:translator.toggle();break;case MSG_TRANS_PUTRULE:translator.updateRule(e.data.args||{});break;default:}});return _context.abrupt("return");case 21:_context.next=23;return getFab();case 23:fab=_context.sent;$action=document.createElement("div");$action.setAttribute("id","kiss-translator");document.body.parentElement.appendChild($action);shadowContainer=$action.attachShadow({mode:"closed"});emotionRoot=document.createElement("style");shadowRootElement=document.createElement("div");shadowContainer.appendChild(emotionRoot);shadowContainer.appendChild(shadowRootElement);cache=(0,emotion_cache_browser_esm/* default */.Z)({key:"css",prepend:true,container:emotionRoot});client.createRoot(shadowRootElement).render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(emotion_element_c39617d8_browser_esm.C,{value:cache,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Action,{translator:translator,fab:fab})})}));// 注册菜单
if(isGm){try{GM.registerMenuCommand("Toggle Translate",function(event){translator.toggle();},"Q");GM.registerMenuCommand("Toggle Style",function(event){translator.toggleStyle();},"C");}catch(err){console.log("[registerMenuCommand]",err);}}// 同步订阅规则 if(isGm){try{GM.registerMenuCommand("Toggle Translate",function(event){translator.toggle();},"Q");GM.registerMenuCommand("Toggle Style",function(event){translator.toggleStyle();},"C");}catch(err){console.log("[registerMenuCommand]",err);}}// 同步订阅规则
trySyncAllSubRules(setting);case 34:case"end":return _context.stop();}},_callee);}));return function init(){return _ref.apply(this,arguments);};}();asyncToGenerator_asyncToGenerator(/*#__PURE__*/regeneratorRuntime_regeneratorRuntime().mark(function _callee2(){var $err;return regeneratorRuntime_regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.prev=0;_context2.next=3;return init();case 3:_context2.next=11;break;case 5:_context2.prev=5;_context2.t0=_context2["catch"](0);$err=document.createElement("div");$err.innerText="KISS-Translator: ".concat(_context2.t0.message);$err.style.cssText="background:red; color:#fff; z-index:10000;";document.body.prepend($err);case 11:case"end":return _context2.stop();}},_callee2,null,[[0,5]]);}))(); trySyncAllSubRules(setting);case 36:case"end":return _context.stop();}},_callee);}));return function init(){return _ref.apply(this,arguments);};}();asyncToGenerator_asyncToGenerator(/*#__PURE__*/regeneratorRuntime_regeneratorRuntime().mark(function _callee2(){var $err;return regeneratorRuntime_regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.prev=0;_context2.next=3;return init();case 3:_context2.next=11;break;case 5:_context2.prev=5;_context2.t0=_context2["catch"](0);$err=document.createElement("div");$err.innerText="KISS-Translator: ".concat(_context2.t0.message);$err.style.cssText="background:red; color:#fff; z-index:10000;";document.body.prepend($err);case 11:case"end":return _context2.stop();}},_callee2,null,[[0,5]]);}))();
}(); }();
/******/ })() /******/ })()
; ;