aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-05-02 17:41:29 -0500
committerJesús <heckyel@hyperbola.info>2020-05-02 17:41:29 -0500
commitc9532aa9677a920d46dad57d1fa87c7c20778264 (patch)
tree03e9030299ba9b2ddc05a48aa551dd382e68b7c3 /js
parent88e55b7e0c00b529e28c1e65b86ee99254a65dfb (diff)
downloadematrix-c9532aa9677a920d46dad57d1fa87c7c20778264.tar.lz
ematrix-c9532aa9677a920d46dad57d1fa87c7c20778264.tar.xz
ematrix-c9532aa9677a920d46dad57d1fa87c7c20778264.zip
Make utils.js a module
The main difference is that modules share their code within the same session.
Diffstat (limited to 'js')
-rw-r--r--js/messaging.js6
-rw-r--r--js/storage.js9
2 files changed, 8 insertions, 7 deletions
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 ) {