diff --git a/.env b/.env index 51cea0e..da4bd05 100644 --- a/.env +++ b/.env @@ -5,3 +5,4 @@ REACT_APP_VERSION=1.3.9 REACT_APP_HOMEPAGE=https://github.com/fishjar/kiss-translator REACT_APP_OPTIONSPAGE=https://kiss-translator.rayjar.com/options REACT_APP_OPTIONSPAGE2=https://fishjar.github.io/kiss-translator/options.html +REACT_APP_OPTIONSPAGE_DEV=http://localhost:3000/options.html diff --git a/src/userscript.js b/src/userscript.js index 8136a51..fd6e545 100644 --- a/src/userscript.js +++ b/src/userscript.js @@ -15,7 +15,7 @@ import { Translator } from "./libs/translator"; (async () => { // 设置页面 if ( - document.location.href.includes("http://localhost:3000/options.html") || + document.location.href.includes(process.env.REACT_APP_OPTIONSPAGE_DEV) || document.location.href.includes(process.env.REACT_APP_OPTIONSPAGE) || document.location.href.includes(process.env.REACT_APP_OPTIONSPAGE2) ) { @@ -24,6 +24,7 @@ import { Translator } from "./libs/translator"; window.unsafeWindow.GM_setValue = window.GM_setValue; window.unsafeWindow.GM_getValue = window.GM_getValue; window.unsafeWindow.GM_deleteValue = window.GM_deleteValue; + window.unsafeWindow.APP_NAME = process.env.REACT_APP_NAME; return; } diff --git a/src/views/Options/index.js b/src/views/Options/index.js index cc86bed..b83f729 100644 --- a/src/views/Options/index.js +++ b/src/views/Options/index.js @@ -23,7 +23,7 @@ export default function Options() { let i = 0; for (;;) { await sleep(1000); - if (window.GM) { + if (window.APP_NAME === process.env.REACT_APP_NAME) { setReady(true); break; }