2020-07-31 08:03:31 +00:00
|
|
|
var core = {};
|
|
|
|
|
|
|
|
core.toggle = function () {
|
|
|
|
var tmp = config.addon.state === "ON" ? "OFF" : "ON";
|
|
|
|
config.addon.state = tmp;
|
|
|
|
};
|
|
|
|
|
|
|
|
core.storage = {
|
|
|
|
"data": function () {
|
|
|
|
return {
|
|
|
|
"state": config.addon.state,
|
|
|
|
/* */
|
|
|
|
"h_svg": config.options.hide.svg,
|
|
|
|
"h_image": config.options.hide.image,
|
|
|
|
"h_flash": config.options.hide.flash,
|
|
|
|
"h_video": config.options.hide.video,
|
|
|
|
"h_canvas": config.options.hide.canvas,
|
|
|
|
"h_iframe": config.options.hide.iframe,
|
|
|
|
"h_background": config.options.hide.background,
|
|
|
|
/* */
|
|
|
|
"b_svg": config.options.block.svg,
|
|
|
|
"b_image": config.options.block.image,
|
|
|
|
"b_flash": config.options.block.flash,
|
|
|
|
"b_video": config.options.block.video,
|
|
|
|
"b_canvas": config.options.block.canvas,
|
|
|
|
"b_iframe": config.options.block.iframe,
|
|
|
|
"b_background": config.options.block.background
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
core.webrequest = {
|
|
|
|
"blocking": {"types": []},
|
|
|
|
"block": function (e) {
|
2020-09-02 10:22:23 +00:00
|
|
|
|
2020-09-02 10:39:21 +00:00
|
|
|
// if(e.url.startsWith("https://video-")) {
|
|
|
|
// return {"cancel": true};
|
|
|
|
// };
|
2020-07-31 08:03:31 +00:00
|
|
|
|
2020-09-02 10:39:21 +00:00
|
|
|
for(var u of ["https://video-", "https://txvid.vod"]) {
|
|
|
|
if(e.url.startsWith(u)) {
|
|
|
|
return {"cancel": true};
|
|
|
|
};
|
|
|
|
}
|
2020-09-02 10:22:23 +00:00
|
|
|
|
2020-07-31 08:03:31 +00:00
|
|
|
var ftp = e.url.indexOf("ftp") === 0;
|
|
|
|
var http = e.url.indexOf("http") === 0;
|
|
|
|
if (http || ftp) {
|
|
|
|
return {"cancel": true};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"update": function () {
|
|
|
|
app.button.icon(config.addon.state);
|
|
|
|
app.content_script.send("storage", core.storage.data());
|
|
|
|
chrome.webRequest.onBeforeRequest.removeListener(core.webrequest.block);
|
|
|
|
/* */
|
|
|
|
if (config.addon.state === "ON") {
|
|
|
|
core.webrequest.blocking.types = [];
|
|
|
|
if (config.options.block.image) core.webrequest.blocking.types.push("image");
|
|
|
|
if (config.options.block.iframe) core.webrequest.blocking.types.push("sub_frame");
|
|
|
|
if (core.webrequest.blocking.types.length > 0) {
|
|
|
|
var options = {"urls": ["*://*/*"], "types": core.webrequest.blocking.types};
|
|
|
|
chrome.webRequest.onBeforeRequest.addListener(core.webrequest.block, options, ["blocking"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
app.options.receive("store", function (e) {
|
|
|
|
var value = e.value;
|
|
|
|
var name = e.id.replace("b_", '').replace("h_", '');
|
|
|
|
var type = e.id.indexOf("b_") !== -1 ? "block" : "hide";
|
|
|
|
/* */
|
|
|
|
config.options[type][name] = value;
|
|
|
|
});
|
|
|
|
|
|
|
|
app.button.clicked(core.toggle);
|
|
|
|
app.storage.changed(core.webrequest.update);
|
|
|
|
window.setTimeout(core.webrequest.update, 300);
|
|
|
|
app.options.receive("support", function () {app.tab.open(app.homepage())});
|
|
|
|
app.options.receive("load", function () {app.options.send("storage", core.storage.data())});
|
|
|
|
app.options.receive("donation", function () {app.tab.open(app.homepage() + "?reason=support")});
|
|
|
|
app.content_script.receive("load", function () {app.content_script.send("storage", core.storage.data())});
|