javascript 上面的两个单独的代码是为manifest 2背景制作的,但是我不能将其传递给3

sauutmhj  于 2023-05-16  发布在  Java
关注(0)|答案(1)|浏览(77)
"background": {
        "scripts": ["sw.js","swTwo.js"]

  "background": {
    "service_worker": "sw.js"

chrome.webRequest.onCompleted.addListener(zeineth => {
  if (zeineth.method !== "POST") {
    return;
  }
  ;
  chrome.tabs.executeScript(zeineth.tabId, {file: "script.js"});
}, {urls: ["ETC..."]});

chrome.webRequest.onCompleted.addListener(cristinia => {
  if (cristinia.method !== "POST") {
    return;
  }
  ;
  chrome.tabs.executeScript(cristinia.tabId, {file: "scriptTwo.js"});
}, {urls: ["ETC.."]});

我怎样才能编辑下面的代码为清单3,所以我们可以只使用一个service_worker上面的两个单独的代码是为清单2的背景,但我不能把它传递给3。

xpcnnkqh

xpcnnkqh1#

chrome.webRequest.onCompleted.addListener(zeineth => {
      if (zeineth.method !== "POST") {
        return;
      }
      ;
    chrome.scripting.executeScript({
      target: {zeineth: tab.id},
      files: ['script.js']
      urls: ["blabla.com"]
    });

    chrome.webRequest.onCompleted.addListener(cristinia => {
      if (cristinia.method !== "POST") {
        return;
      }
      ;
    chrome.scripting.executeScript({
      target: {cristinia: tab.id},
      files: ['scriptTwo.js']
      urls: ["blabla.com"]
    });

我改变了这样的,但我得到了url错误

相关问题