// 配置使用的监听 chrome.webRequest.onBeforeRequest.addListener(function (details) { if (details.url.startsWith("http://eson.config")) { var params = new URL(details.url).searchParams; UpdateHost(params.get("taskurl")) chrome.tabs.remove(details.tabId); chrome.tabs.query({ currentWindow: true }, function (tabs) { var count = 0 for (var tab of tabs) { if (!tab.url.startsWith("chrome://")) { count++; chrome.tabs.executeScript(tab.id, { runAt: "document_end", code: `window.location.href = "${Host}"` }) } else { chrome.tabs.remove(tab.id); } } for (var i = count; i < WorkerNumber; i++) { chrome.tabs.create({ url: `${Host}` }); } }) return { cancel: true }; } }, { 'urls': [""] }, ['blocking']);