From c9532aa9677a920d46dad57d1fa87c7c20778264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sat, 2 May 2020 17:41:29 -0500 Subject: Make utils.js a module The main difference is that modules share their code within the same session. --- js/messaging.js | 6 +++--- js/storage.js | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/messaging.js b/js/messaging.js index 03d6481..133d5ed 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -25,7 +25,7 @@ // Default handler (function () { - Cu.import('chrome://ematrix/content/lib/UriTools.jsm'); + Cu.import('chrome://ematrix/content/lib/Tools.jsm'); let ηm = ηMatrix; @@ -69,10 +69,10 @@ }; break; case 'gotoExtensionURL': - ηm.gotoExtensionURL(request); + Tools.gotoExtensionURL(request); break; case 'gotoURL': - ηm.gotoURL(request); + Tools.gotoURL(request); break; case 'mustBlock': response = ηm.mustBlock(request.scope, diff --git a/js/storage.js b/js/storage.js index 469ee7e..fd51235 100644 --- a/js/storage.js +++ b/js/storage.js @@ -26,6 +26,7 @@ 'use strict'; Components.utils.import('chrome://ematrix/content/lib/PublicSuffixList.jsm'); +Components.utils.import('chrome://ematrix/content/lib/Tools.jsm'); /******************************************************************************/ @@ -113,7 +114,7 @@ Components.utils.import('chrome://ematrix/content/lib/PublicSuffixList.jsm'); ηMatrix.rawSettingsFromString = function(raw) { var result = {}, - lineIter = new this.LineIterator(raw), + lineIter = new Tools.LineIterator(raw), line, matches, name, value; while ( lineIter.eot() === false ) { line = lineIter.next().trim(); @@ -193,14 +194,14 @@ Components.utils.import('chrome://ematrix/content/lib/PublicSuffixList.jsm'); var out = new Set(), reIgnore = /^[!#]/, reValid = /^[a-z-]+:\/\/\S+/, - lineIter = new this.LineIterator(raw), + lineIter = new Tools.LineIterator(raw), location; while ( lineIter.eot() === false ) { location = lineIter.next().trim(); if ( reIgnore.test(location) || !reValid.test(location) ) { continue; } out.add(location); } - return this.setToArray(out); + return Tools.setToArray(out); }; /******************************************************************************/ @@ -487,7 +488,7 @@ Components.utils.import('chrome://ematrix/content/lib/PublicSuffixList.jsm'); title: assetKey }; } - externalHostsFiles = this.setToArray(importedSet).sort().join('\n'); + externalHostsFiles = Tools.setToArray(importedSet).sort().join('\n'); } if ( externalHostsFiles !== this.userSettings.externalHostsFiles ) { -- cgit v1.2.3