2020-11-17 11:42:36 +00:00
|
|
|
|
2020-11-18 11:49:46 +00:00
|
|
|
|
|
|
|
chrome.runtime.onMessage.addListener(function (request) {
|
|
|
|
switch(request.type) {
|
|
|
|
case InjectMsgType.WAIT:
|
|
|
|
setTimeout(function(){
|
|
|
|
GetTask();
|
|
|
|
}, 6000);
|
|
|
|
break;
|
|
|
|
case InjectMsgType.NOTASK:
|
|
|
|
setTimeout(function(){
|
|
|
|
GetTask();
|
|
|
|
}, 4000);
|
|
|
|
break;
|
|
|
|
case InjectMsgType.FETCH:
|
|
|
|
setTimeout(function(){
|
|
|
|
GetTask();
|
|
|
|
}, 6000)
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// chrome.runtime.onMessage.removeListener(assignTextToTextareas); //optional
|
|
|
|
});
|
|
|
|
|
|
|
|
if(typeof chrome.app.isInstalled != undefined){
|
|
|
|
var href = window.location.href;
|
|
|
|
var content = document.documentElement.innerHTML;
|
|
|
|
|
|
|
|
if (href.startsWith("https://playerduo.com") && content.startsWith('<head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">')) {
|
|
|
|
// SendContent();
|
|
|
|
Tell(BackgroundMsgType.CONTENT, content);
|
|
|
|
} else {
|
|
|
|
// NotWant()
|
|
|
|
Tell(BackgroundMsgType.NOTWANT, content)
|
|
|
|
}
|
2020-11-17 11:54:25 +00:00
|
|
|
} else {
|
2020-11-18 11:49:46 +00:00
|
|
|
console.log(chrome.app);
|
2020-11-16 11:04:53 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 11:49:46 +00:00
|
|
|
function Tell(backgroundType, content) {
|
|
|
|
if(content == undefined) {
|
|
|
|
chrome.runtime.sendMessage({type: backgroundType});
|
|
|
|
} else {
|
|
|
|
chrome.runtime.sendMessage({type: backgroundType, content: content});
|
|
|
|
}
|
2020-11-17 11:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function GetTask() {
|
2020-11-18 11:49:46 +00:00
|
|
|
Tell(BackgroundMsgType.GETTASK);
|
2020-11-17 11:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-16 11:04:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|