TODO: 回调没反应

This commit is contained in:
eson
2020-11-23 18:50:25 +08:00
parent 4a60282e7e
commit 5c6dc47d47
7 changed files with 58 additions and 14 deletions

View File

@@ -23,20 +23,28 @@ chrome.runtime.onMessage.addListener(function (request) {
});
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;">')) {
// var href = window.location.href;
// var content = document.documentElement.innerHTML;
var condition = PassContentCondition != undefined ? PassContentCondition : DefaultContentCondition;
if (condition()) {
Tell(BackgroundMsgType.CONTENT, content);
} else {
Tell(BackgroundMsgType.NOTWANT, content);
}
function Tell(backgroundType, content) {
if(content == undefined) {
chrome.runtime.sendMessage({type: backgroundType});
} else {
chrome.runtime.sendMessage({type: backgroundType, content: content});
try {
if(content == undefined) {
chrome.runtime.sendMessage({type: backgroundType});
} else {
chrome.runtime.sendMessage({type: backgroundType, content: content});
}
} catch (error) {
console.log(error);
window.location.href = Host;
}
}
function GetTask() {