Index: lib/devtools.js |
=================================================================== |
--- a/lib/devtools.js |
+++ b/lib/devtools.js |
@@ -10,27 +10,23 @@ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-"use strict"; |
- |
-const {RegExpFilter, |
- WhitelistFilter, |
- ElemHideFilter} = require("filterClasses"); |
-const {SpecialSubscription} = require("subscriptionClasses"); |
-const {FilterStorage} = require("filterStorage"); |
-const {defaultMatcher} = require("matcher"); |
-const {FilterNotifier} = require("filterNotifier"); |
-const {extractHostFromFrame} = require("url"); |
-const {port} = require("messaging"); |
+import {RegExpFilter, WhitelistFilter, ElemHideFilter} from "filterClasses"; |
+import {SpecialSubscription} from "subscriptionClasses"; |
+import {FilterStorage} from "filterStorage"; |
+import {defaultMatcher} from "matcher"; |
+import {FilterNotifier} from "filterNotifier"; |
+import {extractHostFromFrame} from "url"; |
+import {port} from "messaging"; |
const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", "GENERICBLOCK", "GENERICHIDE"]; |
// Mapping of inspected tabs to their devpanel page |
// and recorded items. We can't use a PageMap here, |
// because data must persist after navigation/reload. |
let panels = new Map(); |
@@ -128,28 +124,27 @@ |
* @param {string} docDomain The IDN-decoded hostname of the document |
* @param {boolean} thirdParty Whether the origin of the request and |
* document differs |
* @param {?string} sitekey The active sitekey if there is any |
* @param {?boolean} specificOnly Whether generic filters should be ignored |
* @param {?BlockingFilter} filter The matched filter or null if there is no |
* match |
*/ |
-exports.logRequest = function(page, url, type, docDomain, |
- thirdParty, sitekey, |
- specificOnly, filter) |
+export function logRequest(page, url, type, docDomain, thirdParty, sitekey, |
+ specificOnly, filter) |
{ |
if (panels.size == 0) |
return; |
let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; |
for (let [tabId, panel] of panels) |
if ((!page || page.id == tabId) && isActivePanel(panel)) |
addRecord(panel, request, filter); |
-}; |
+} |
/** |
* Logs active element hiding filters to the devtools panel. |
* |
* @param {Page} page The page the elements were hidden on |
* @param {string[]} selectors The selectors of applied ElemHideFilters |
* @param {string[]} filters The text of applied ElemHideEmulationFilters |
* @param {string} docDomain The IDN-decoded hostname of the document |
@@ -188,40 +183,39 @@ |
* @param {Page} page The page the whitelisting is active on |
* @param {string} url The url of the whitelisted document |
* @param {number} typeMask The bit mask of whitelisting types checked |
* for |
* @param {string} docDomain The IDN-decoded hostname of the parent |
* document |
* @param {WhitelistFilter} filter The matched whitelisting filter |
*/ |
-exports.logWhitelistedDocument = function(page, url, typeMask, docDomain, |
- filter) |
+export function logWhitelistedDocument(page, url, typeMask, docDomain, filter) |
{ |
let panel = getActivePanel(page); |
if (panel) |
{ |
for (let type of nonRequestTypes) |
{ |
if (typeMask & filter.contentType & RegExpFilter.typeMap[type]) |
addRecord(panel, {url, type, docDomain}, filter); |
} |
} |
-}; |
+} |
/** |
* Checks whether a page is inspected by the devtools panel. |
* |
* @param {Page} page |
* @return {boolean} |
*/ |
-exports.hasPanel = function(page) |
+export function hasPanel(page) |
{ |
return panels.has(page.id); |
-}; |
+} |
function onBeforeRequest(details) |
{ |
let panel = panels.get(details.tabId); |
// Clear the devtools panel and reload the inspected tab without caching |
// when a new request is issued. However, make sure that we don't end up |
// in an infinite recursion if we already triggered a reload. |