From df950a1bd2aaf4d4fa50cbd167ab150b0bf9929f Mon Sep 17 00:00:00 2001 From: Gabe Yuan Date: Tue, 29 Aug 2023 01:17:22 +0800 Subject: [PATCH] use createElement script --- src/userscript.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/userscript.js b/src/userscript.js index 168efa5..695e4e5 100644 --- a/src/userscript.js +++ b/src/userscript.js @@ -25,7 +25,12 @@ const init = async () => { // unsafeWindow.APP_NAME = process.env.REACT_APP_NAME; const ping = btoa(Math.random()).slice(3, 11); window.addEventListener(ping, handlePing); - window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line + // window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line + const script = document.createElement("script"); + script.textContent = `(${injectScript})("${ping}")`; + if (document.head) { + document.head.append(script); + } return; }