fix(closetab): 1.fix close tab. 2.waittime default = 6000
This commit is contained in:
parent
7b5c3717ba
commit
899f554336
1
chromeproxy/.vscode/launch.json
vendored
1
chromeproxy/.vscode/launch.json
vendored
@ -14,6 +14,7 @@
|
|||||||
"--ignore-certificate-errors",
|
"--ignore-certificate-errors",
|
||||||
"--disable-dev-shm-usage",
|
"--disable-dev-shm-usage",
|
||||||
"--mute-audio",
|
"--mute-audio",
|
||||||
|
"--single-process",
|
||||||
"--safebrowsing-disable-auto-update",
|
"--safebrowsing-disable-auto-update",
|
||||||
"--disable-gpu",
|
"--disable-gpu",
|
||||||
"--no-sandbox",
|
"--no-sandbox",
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
|
||||||
var href = window.location.href;
|
var href = window.location.href;
|
||||||
var content = document.documentElement.innerHTML;
|
var content = document.documentElement.innerHTML;
|
||||||
|
|
||||||
setTimeout(function(){
|
try {
|
||||||
window.close();
|
if(waittime === undefined) {
|
||||||
}, 15000)
|
waittime = 6000
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
waittime = 6000
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (condition == undefined) {
|
if (condition == undefined) {
|
||||||
condition = function () {
|
condition = function () {
|
||||||
@ -12,11 +16,17 @@ if (condition == undefined) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (condition()) {
|
||||||
|
Tell(BackgroundMsgType.CONTENT, content);
|
||||||
|
} else {
|
||||||
|
setTimeout(function () {
|
||||||
if (condition()) {
|
if (condition()) {
|
||||||
Tell(BackgroundMsgType.CONTENT, content);
|
Tell(BackgroundMsgType.CONTENT, content);
|
||||||
} else {
|
} else {
|
||||||
Tell(BackgroundMsgType.NOTWANT, content);
|
Tell(BackgroundMsgType.NOTWANT, content);
|
||||||
}
|
}
|
||||||
|
}, waittime)
|
||||||
|
}
|
||||||
|
|
||||||
function Tell(backgroundType, content) {
|
function Tell(backgroundType, content) {
|
||||||
try {
|
try {
|
||||||
|
@ -16,7 +16,15 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|||||||
GetTask(sender);
|
GetTask(sender);
|
||||||
break;
|
break;
|
||||||
case BackgroundMsgType.NOTWANT:
|
case BackgroundMsgType.NOTWANT:
|
||||||
|
|
||||||
|
task = task_manager[sender.tab.id];
|
||||||
|
task.data.retry --;
|
||||||
|
if(task.data.retry >= 0) {
|
||||||
|
CaptureContent(task);
|
||||||
|
} else {
|
||||||
ErrorTask(sender, request.content);
|
ErrorTask(sender, request.content);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -27,6 +35,7 @@ function GetTask(sender) {
|
|||||||
fetch(GetTaskUrl).then(function (response) {
|
fetch(GetTaskUrl).then(function (response) {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
response.json().then(function (task) {
|
response.json().then(function (task) {
|
||||||
|
|
||||||
CaptureContent(task);
|
CaptureContent(task);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -41,6 +50,11 @@ function GetTask(sender) {
|
|||||||
|
|
||||||
function CaptureContent(task) {
|
function CaptureContent(task) {
|
||||||
if (task.code == 200) {
|
if (task.code == 200) {
|
||||||
|
|
||||||
|
if(task.data.retry == undefined) {
|
||||||
|
task.data.retry = 1;
|
||||||
|
}
|
||||||
|
|
||||||
chrome.tabs.create({ url: task.data.url }, function (tab) {
|
chrome.tabs.create({ url: task.data.url }, function (tab) {
|
||||||
task_manager[tab.id] = task;
|
task_manager[tab.id] = task;
|
||||||
if (task.data.content_condition) {
|
if (task.data.content_condition) {
|
||||||
@ -60,6 +74,7 @@ function CaptureContent(task) {
|
|||||||
function FinishTask(sender, content) {
|
function FinishTask(sender, content) {
|
||||||
var task = task_manager[sender.tab.id];
|
var task = task_manager[sender.tab.id];
|
||||||
var formdata = new FormData();
|
var formdata = new FormData();
|
||||||
|
|
||||||
formdata.append("taskid", task.data.taskid);
|
formdata.append("taskid", task.data.taskid);
|
||||||
formdata.append("content", content);
|
formdata.append("content", content);
|
||||||
|
|
||||||
|
@ -3,6 +3,10 @@ if(href.startsWith(Host)) {
|
|||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
GetTask();
|
GetTask();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
} else {
|
||||||
|
setTimeout(function(){
|
||||||
|
close();
|
||||||
|
}, 15000)
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetTask() {
|
function GetTask() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user