chromeworker/chromeproxy/background/capture.js
2020-11-27 15:57:24 +08:00

41 lines
861 B
JavaScript

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;
}
}
try {
if (condition == undefined) {
condition = function () {
return true;
};
}
} catch (error) {
condition = function () {
return true;
};
}
var href = window.location.href;
var content = "";
if(document.contentType == "application/json") {
content = document.documentElement.innerText;
} else {
content = document.documentElement.innerHTML;
}
if (condition()) {
Tell("content", content);
} else {
Tell("notwant", content);
}