Index: lib/filterComposer.js |
=================================================================== |
--- a/lib/filterComposer.js |
+++ b/lib/filterComposer.js |
@@ -17,10 +17,13 @@ |
/** @module filterComposer */ |
+"use strict"; |
+ |
let {extractHostFromFrame, stringifyURL, isThirdParty} = require("url"); |
let {getKey, checkWhitelisted} = require("whitelisting"); |
let {defaultMatcher} = require("matcher"); |
let {RegExpFilter} = require("filterClasses"); |
+let {port} = require("messaging"); |
function isValidString(s) { |
return s && s.indexOf("\0") == -1; |
@@ -66,25 +69,7 @@ |
return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"'; |
}; |
-/** |
kzar
2016/03/18 15:22:10
Any reason you deleted this documentation? (I unde
Sebastian Noack
2016/03/18 15:26:21
I found the documentation for this function quite
kzar
2016/03/18 15:52:39
I think it's useful but if you disagree I guess we
|
- * Generates filters to block an element. |
- * @param {Object} details |
- * @param {string} details.tagName The element's tag name |
- * @param {string} details.id The element's "id" attribute |
- * @param {string} details.src The element's "src" attribute |
- * @param {string} details.style The element's "style" attribute |
- * @param {string[]} details.classes The classes given by the element's "class" attribute |
- * @param {string[]} details.urls The URLs considered when loading the element |
- * @param {string} details.type The request type (will be ignored if there are no URLs) |
- * @param {string} details.baseURL The URL of the document containing the element |
- * @param {Page} details.page The page containing the element |
- * @param {Frame} details.frame The frame containing the element |
- * |
- * @return {object} An object holding the list of generated filters and |
- * the list of CSS selectors for the included element |
- * hiding filters: {filters: [...], selectors: [...]} |
- */ |
-exports.composeFilters = function(details) |
+function composeFilters(details) |
{ |
let filters = []; |
let selectors = []; |
@@ -151,4 +136,59 @@ |
} |
return {filters: filters, selectors: selectors}; |
-}; |
+} |
+ |
+port.on("composer.ready", (message, sender) => |
+{ |
+ htmlPages.set(sender.page, null); |
+ refreshIconAndContextMenu(sender.page); |
+}); |
+ |
+port.on("composer.openDialog", (message, sender) => |
+{ |
+ return new Promise(resolve => |
+ { |
+ ext.windows.create({ |
+ url: ext.getURL("block.html"), |
+ left: 50, |
+ top: 50, |
+ width: 420, |
+ height: 200, |
+ focused: true, |
+ type: "popup" |
+ }, |
+ popupPage => |
+ { |
+ let popupPageId = popupPage.id; |
+ function onRemoved(removedPageId) |
+ { |
+ if (popupPageId == removedPageId) |
+ { |
+ sender.page.sendMessage({ |
+ type: "blockelement-popup-closed", |
+ popupId: popupPageId |
+ }); |
+ ext.pages.onRemoved.removeListener(onRemoved); |
+ } |
+ } |
+ ext.pages.onRemoved.addListener(onRemoved); |
+ resolve(popupPageId); |
+ }); |
+ }); |
+}); |
+ |
+port.on("composer.getFilters", (message, sender) => |
+{ |
+ return composeFilters({ |
+ tagName: message.tagName, |
+ id: message.id, |
+ src: message.src, |
+ style: message.style, |
+ classes: message.classes, |
+ urls: message.urls, |
+ type: message.mediatype, |
+ baseURL: message.baseURL, |
+ page: sender.page, |
+ frame: sender.frame |
+ }); |
+}); |