在谷歌浏览器插件中,注入JS代码到页面里

Published on
10

第一种:

const script = document.createElement("script");
script.textContent = `代码`
document.documentElement.appendChild(script);
script.remove(); 

第二种:

    const inlineScript = `
        (function() {
          代码
        })();
      `;

      const scriptTag = document.createElement('script');
      scriptTag.textContent = inlineScript;
      document.head.appendChild(scriptTag);
      scriptTag.remove();

好用的插件开发框架:wxt.dev


Prev Post Windows 10 Enterprise LTSC 2021激活
Next Post [Python] Turnstile验证示例