TODO: worker.js 完善接收数据的方案.
This commit is contained in:
parent
9ec4a86611
commit
324322cf23
|
@ -1,31 +1,33 @@
|
|||
|
||||
|
||||
|
||||
var href = window.location.href;
|
||||
var content = document.documentElement.innerHTML;
|
||||
|
||||
var interval = setInterval(function(){
|
||||
GetTask();
|
||||
}, 6000)
|
||||
|
||||
if (href.startsWith("https://playerduo.com")) {
|
||||
if (content.startsWith('<head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">')) {
|
||||
if (href.startsWith("https://playerduo.com") && content.startsWith('<head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">')) {
|
||||
SendContent();
|
||||
clearInterval(interval);
|
||||
GetTask();
|
||||
}
|
||||
} else {
|
||||
GetTask()
|
||||
}
|
||||
|
||||
|
||||
function SendContent() {
|
||||
chrome.runtime.sendMessage({ type: BackgroundMsgType.CONTENT, content: content },
|
||||
function (response) {
|
||||
console.log(response.type, response);
|
||||
console.log(response);
|
||||
GetTask();
|
||||
})
|
||||
}
|
||||
|
||||
function GetTask() {
|
||||
chrome.runtime.sendMessage({ type: BackgroundMsgType.GETTASK }, function (response) {
|
||||
console.log(response);
|
||||
switch(response.type) {
|
||||
case BackgroundMsgType.FETCH:
|
||||
setTimeout(function(){
|
||||
GetTask();
|
||||
}, 6000)
|
||||
case BackgroundMsgType.WAIT:
|
||||
setTimeout(function(){
|
||||
GetTask();
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user