42 lines
930 B
JavaScript
42 lines
930 B
JavaScript
var href = window.location.href;
|
|
var content = document.documentElement.innerHTML;
|
|
|
|
try {
|
|
if(waittime === undefined) {
|
|
waittime = 6000
|
|
}
|
|
} catch (error) {
|
|
waittime = 6000
|
|
}
|
|
|
|
|
|
if (condition == undefined) {
|
|
condition = function () {
|
|
return true;
|
|
};
|
|
}
|
|
|
|
if (condition()) {
|
|
Tell(BackgroundMsgType.CONTENT, content);
|
|
} else {
|
|
setTimeout(function () {
|
|
if (condition()) {
|
|
Tell(BackgroundMsgType.CONTENT, content);
|
|
} else {
|
|
Tell(BackgroundMsgType.NOTWANT, content);
|
|
}
|
|
}, waittime)
|
|
}
|
|
|
|
function Tell(backgroundType, 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;
|
|
}
|
|
} |