Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: background.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use Location.pathname Created Oct. 18, 2017, 12:23 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | desktop-options.js » ('j') | ext/background.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -74,20 +74,18 @@
filterError: false,
downloadStatus: "synchronize_ok",
showNotificationUI: false,
showPageOptions: false
};
updateFromURL(params);
let modules = {};
- window.require = function(module)
- {
- return modules[module];
- };
+
+ window.require = module => modules[module];
modules.utils = {
Utils: {
getDocLink(link)
{
return "https://adblockplus.org/redirect?link=" + encodeURIComponent(link);
},
get appLocale()
@@ -413,16 +411,20 @@
if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href))
window.open("desktop-options.html", "_blank");
if (callback)
callback();
}
};
+ modules.requestBlocker = {
+ filterTypes: []
+ };
+
window.addEventListener("message", (event) =>
{
if (event.data.type != "message")
return;
let message = event.data.payload;
let {messageId} = event.data;
let sender = {
page: new ext.Page(event.source)
@@ -536,78 +538,78 @@
whitelisted: isWhitelisted
}
]
}
}, "*");
}, 1000);
}
- ext.devtools.onCreated.addListener((panel) =>
+ chrome.runtime.onConnect.addListener(port =>
{
// blocked request
- panel.sendMessage({
+ port.postMessage({
type: "add-record",
request: {
url: "http://adserver.example.com/ad_banner.png",
type: "IMAGE",
docDomain: "example.com"
},
filter: {
text: "/ad_banner*$domain=example.com",
whitelisted: false,
userDefined: false,
subscription: "EasyList"
}
});
// whitelisted request
- panel.sendMessage({
+ port.postMessage({
type: "add-record",
request: {
url: "http://example.com/looks_like_an_ad_but_isnt_one.html",
type: "SUBDOCUMENT",
docDomain: "example.com"
},
filter: {
text: "@@||example.com/looks_like_an_ad_but_isnt_one.html",
whitelisted: true,
userDefined: false,
subscription: "EasyList"
}
});
// request with long URL and no filter matches
- panel.sendMessage({
+ port.postMessage({
type: "add-record",
request: {
url: "https://this.url.has.a.long.domain/and_a_long_path_maybe_not_long_enough_so_i_keep_typing?there=are&a=couple&of=parameters&as=well&and=even&some=more",
type: "XMLHTTPREQUEST",
docDomain: "example.com"
},
filter: null
});
// matching element hiding filter
- panel.sendMessage({
+ port.postMessage({
type: "add-record",
request: {
type: "ELEMHIDE",
docDomain: "example.com"
},
filter: {
text: "example.com##.ad_banner",
whitelisted: false,
userDefined: false,
subscription: "EasyList"
}
});
// user-defined filter
- panel.sendMessage({
+ port.postMessage({
type: "add-record",
request: {
url: "http://example.com/some-annoying-popup",
type: "POPUP",
docDomain: "example.com"
},
filter: {
text: "||example.com/some-annoying-popup$popup",
« no previous file with comments | « no previous file | desktop-options.js » ('j') | ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld