stable
This commit is contained in:
@@ -33,8 +33,8 @@ if(document.contentType == "application/json") {
|
||||
}
|
||||
|
||||
if (condition()) {
|
||||
Tell(BackgroundMsgType.CONTENT, content);
|
||||
Tell("content", content);
|
||||
} else {
|
||||
Tell(BackgroundMsgType.NOTWANT, content);
|
||||
Tell("notwant", content);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,40 @@
|
||||
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( key of params.keys()) {
|
||||
switch(key) {
|
||||
case "proxyserver":
|
||||
ProxyServer = params.get(key)
|
||||
break
|
||||
}
|
||||
for (var i = count; i < WorkerNumber; i++) {
|
||||
chrome.tabs.create({ url: `${Host}` });
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var taskurl = params.get("taskurl")
|
||||
if(taskurl !== "") {
|
||||
UpdateHost(taskurl)
|
||||
removeConfigTabAndCreateGetTaskTab(details);
|
||||
}
|
||||
|
||||
return { cancel: true };
|
||||
}
|
||||
}, { 'urls': ["<all_urls>"] }, ['blocking']);
|
||||
}, { 'urls': ["<all_urls>"] }, ['blocking']);
|
||||
|
||||
|
||||
function removeConfigTabAndCreateGetTaskTab(details) {
|
||||
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}` });
|
||||
}
|
||||
})
|
||||
}
|
||||
21
chromeproxy/background/proxy.js
Normal file
21
chromeproxy/background/proxy.js
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
var config = {
|
||||
mode: "pac_script",
|
||||
pacScript: {
|
||||
data:
|
||||
`
|
||||
ProxyServer = ${ProxyServer};
|
||||
function FindProxyForURL(url, host) {
|
||||
if(ProxyServer != undefined) {
|
||||
return ProxyServer;
|
||||
}
|
||||
return 'DIRECT';
|
||||
}`
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
chrome.proxy.settings.set(
|
||||
{ value: config, scope: 'regular' },
|
||||
function () { });
|
||||
@@ -61,9 +61,7 @@ function GetTask(sender) {
|
||||
}
|
||||
|
||||
function CaptureContentCurrentPage(tabid) {
|
||||
chrome.tabs.executeScript(tabid, { runAt: "document_end", file: "base.js" }, function(){
|
||||
chrome.tabs.executeScript(tabid, { runAt: "document_end", file: "background/capture.js" });
|
||||
});
|
||||
chrome.tabs.executeScript(tabid, { runAt: "document_end", file: "background/capture.js" });
|
||||
}
|
||||
|
||||
function CaptureContent(task) {
|
||||
@@ -82,7 +80,7 @@ function CaptureContent(task) {
|
||||
}
|
||||
|
||||
if (condition != undefined) {
|
||||
chrome.tabs.executeScript(tab.id, { runAt: "document_end", code: condition }, function () {
|
||||
chrome.tabs.executeScript(tab.id, { runAt: "document_start", code: condition }, function () {
|
||||
CaptureContentCurrentPage(tab.id)
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user