aboutsummaryrefslogtreecommitdiffstats
path: root/frameScript.js
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-12-30 15:55:13 -0500
committerJesús <heckyel@hyperbola.info>2019-12-30 15:55:13 -0500
commit288df6a7bf8b933e2dc499e38f4915fcf974c14b (patch)
tree77bba994f260c064d3ee7f76c427ddfaa4f91710 /frameScript.js
parenta2c9deaa145b780722e93b3899600f287c8094a4 (diff)
downloadematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.tar.lz
ematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.tar.xz
ematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.zip
backport
- Flush caches on upgrade - Properly handle FrameModule's unloading - Use the new module and remove the old implementation
Diffstat (limited to 'frameScript.js')
-rw-r--r--frameScript.js43
1 files changed, 16 insertions, 27 deletions
diff --git a/frameScript.js b/frameScript.js
index e4b2dbe..cc1a564 100644
--- a/frameScript.js
+++ b/frameScript.js
@@ -21,54 +21,43 @@
uMatrix Home: https://github.com/gorhill/uMatrix
*/
-/******************************************************************************/
+'use strict';
-var locationChangeListener; // Keep alive while frameScript is alive
-
-(function() {
-
- 'use strict';
+Components.utils.import('chrome://ematrix/content/lib/FrameModule.jsm');
- /******************************************************************************/
-
- let {contentObserver, LocationChangeListener} = Components.utils.import(
- Components.stack.filename.replace('Script', 'Module'),
- null
- );
+var locationChangeListener; // Keep alive while frameScript is alive
- let injectContentScripts = function(win) {
- if ( !win || !win.document ) {
+(function () {
+ let injectContentScripts = function (win) {
+ if (!win || !win.document) {
return;
}
contentObserver.observe(win.document);
- if ( win.frames && win.frames.length ) {
- let i = win.frames.length;
- while ( i-- ) {
+ if (win.frames && win.frames.length) {
+ for (let i = win.frames.length; i>0; --i) {
injectContentScripts(win.frames[i]);
}
}
};
- let onLoadCompleted = function() {
+ let onLoadCompleted = function () {
removeMessageListener('ematrix-load-completed', onLoadCompleted);
injectContentScripts(content);
};
addMessageListener('ematrix-load-completed', onLoadCompleted);
- if ( docShell ) {
+ if (docShell) {
let Ci = Components.interfaces;
- let wp = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress);
+ let wp = docShell
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebProgress);
let dw = wp.DOMWindow;
- if ( dw === dw.top ) {
+
+ if (dw === dw.top) {
locationChangeListener = new LocationChangeListener(docShell);
}
- };
-
- /******************************************************************************/
-
+ }
})();
-
-/******************************************************************************/