diff --git a/lib/askForPermission.js b/lib/askForPermission.js index 8a5a4f8..0f5835b 100644 --- a/lib/askForPermission.js +++ b/lib/askForPermission.js @@ -8,8 +8,7 @@ scope = exports; } else { - window.scope.askForPermission = {}; - scope = window.scope.askForPermission; + scope = require.register("./askForPermission", {}); } const {parseErrorStack} = require("./callingStack"); diff --git a/lib/callingStack.js b/lib/callingStack.js index 8d13f45..3e4a4d5 100644 --- a/lib/callingStack.js +++ b/lib/callingStack.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.callingStack = {}; - scope = window.scope.callingStack; + scope = require.register("./callingStack", {}); } const settings = require("./settings"); diff --git a/lib/check.js b/lib/check.js index 2081c63..d8d2080 100644 --- a/lib/check.js +++ b/lib/check.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.check = {}; - scope = window.scope.check; + scope = require.register("./check", {}); } const settings = require("./settings"); diff --git a/lib/colorStatistics.js b/lib/colorStatistics.js index 2bb8df4..1438e55 100644 --- a/lib/colorStatistics.js +++ b/lib/colorStatistics.js @@ -10,8 +10,7 @@ scope = exports; } else { - window.scope.colorStatistics = {}; - scope = window.scope.colorStatistics; + scope = require.register("./colorStatistics", {}); } class Statistic{ diff --git a/lib/dataUrls.js b/lib/dataUrls.js index b932053..8962974 100644 --- a/lib/dataUrls.js +++ b/lib/dataUrls.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.dataUrls = {}; - scope = window.scope.dataUrls; + scope = require.register("./dataUrls", {}); } const logging = require("./logging"); diff --git a/lib/frame.js b/lib/frame.js index 36ae47e..2279df2 100644 --- a/lib/frame.js +++ b/lib/frame.js @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -(function(){ +(function(require){ "use strict"; const settings = require("./settings"); @@ -171,4 +171,4 @@ }); interceptWindow(window); -}()); \ No newline at end of file +}(require)); \ No newline at end of file diff --git a/lib/hash.js b/lib/hash.js index d185a9a..c4958bf 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.hash = {}; - scope = window.scope.hash; + scope = require.register("./hash", {}); } scope.byteArrayToString = function byteArrayToString(byteArray){ return String.fromCharCode.apply(String, new Uint16Array(byteArray.buffer)); diff --git a/lib/intercept.js b/lib/intercept.js index 8f5ce81..8dc1d74 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.intercept = {}; - scope = window.scope.intercept; + scope = require.register("./intercept", {}); } const {changedFunctions, changedGetters, setRandomSupply} = require("./modifiedAPI"); diff --git a/lib/lists.js b/lib/lists.js index c1bd478..2e263c5 100644 --- a/lib/lists.js +++ b/lib/lists.js @@ -11,8 +11,7 @@ scope = exports; } else { - window.scope.lists = {}; - scope = window.scope.lists; + scope = require.register("./lists", {}); } var settings = require("./settings"); diff --git a/lib/logging.js b/lib/logging.js index 8c12921..f96eddc 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -10,10 +10,12 @@ scope = exports; } else { - if (!window.scope.logging){ - window.scope.logging = {}; + if (require.exists("./logging")){ + scope = require("./logging"); + } + else { + scope = require.register("./logging", {}); } - scope = window.scope.logging; } let settings = false; diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 873c643..cc47591 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedAPI = {}; - scope = window.scope.modifiedAPI; + scope = require.register("./modifiedAPI", {}); } const colorStatistics = require("./colorStatistics"); diff --git a/lib/modifiedAPIFunctions.js b/lib/modifiedAPIFunctions.js index 9b7a31a..d82143c 100644 --- a/lib/modifiedAPIFunctions.js +++ b/lib/modifiedAPIFunctions.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedAPIFunctions = {}; - scope = window.scope.modifiedAPIFunctions; + scope = require.register("./modifiedAPIFunctions", {}); } scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){ diff --git a/lib/modifiedAudioAPI.js b/lib/modifiedAudioAPI.js index 6a54b80..6c60be4 100644 --- a/lib/modifiedAudioAPI.js +++ b/lib/modifiedAudioAPI.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedAudioAPI = {}; - scope = window.scope.modifiedAudioAPI; + scope = require.register("./modifiedAudioAPI", {}); } const logging = require("./logging"); diff --git a/lib/modifiedDOMRectAPI.js b/lib/modifiedDOMRectAPI.js index efce4dd..2bb74f3 100644 --- a/lib/modifiedDOMRectAPI.js +++ b/lib/modifiedDOMRectAPI.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedDOMRectAPI = {}; - scope = window.scope.modifiedDOMRectAPI; + scope = require.register("./modifiedDOMRectAPI", {}); } const {checkerWrapper, setProperties: setProperties} = require("./modifiedAPIFunctions"); diff --git a/lib/modifiedHistoryAPI.js b/lib/modifiedHistoryAPI.js index f44758e..0632596 100644 --- a/lib/modifiedHistoryAPI.js +++ b/lib/modifiedHistoryAPI.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedHistoryAPI = {}; - scope = window.scope.modifiedHistoryAPI; + scope = require.register("./modifiedHistoryAPI", {}); } const {checkerWrapper} = require("./modifiedAPIFunctions"); diff --git a/lib/modifiedWindowAPI.js b/lib/modifiedWindowAPI.js index d1ec1e1..e9d94d6 100644 --- a/lib/modifiedWindowAPI.js +++ b/lib/modifiedWindowAPI.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.modifiedWindowAPI = {}; - scope = window.scope.modifiedWindowAPI; + scope = require.register("./modifiedWindowAPI", {}); } const {checkerWrapper} = require("./modifiedAPIFunctions"); diff --git a/lib/notification.js b/lib/notification.js index 8d17ead..41c4d42 100644 --- a/lib/notification.js +++ b/lib/notification.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.notification = scope; + scope = require.register("./notification", {}); } const settings = require("./settings"); diff --git a/lib/persistentRndStorage.js b/lib/persistentRndStorage.js index da56099..515edb7 100644 --- a/lib/persistentRndStorage.js +++ b/lib/persistentRndStorage.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.persistentRndStorage = scope; + scope = require.register("./persistentRndStorage", {}); } diff --git a/lib/randomSupplies.js b/lib/randomSupplies.js index 10dcfa6..892416d 100644 --- a/lib/randomSupplies.js +++ b/lib/randomSupplies.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.randomSupplies = {}; - scope = window.scope.randomSupplies; + scope = require.register("./randomSupplies", {}); } const rngTemplate = { diff --git a/lib/require.js b/lib/require.js index fcd9053..c848ee6 100644 --- a/lib/require.js +++ b/lib/require.js @@ -39,13 +39,14 @@ const require = function(){ } require.register = function(moduleName, module = {}){ + const scopeName = getScopeName(moduleName); if (!require.exists(moduleName)){ - const scopeName = getScopeName(moduleName); scope[scopeName] = module; return module; } else { require("./logging").error("Module", moduleName, "already registered."); + return scope[scopeName]; } }; diff --git a/lib/search.js b/lib/search.js index 840d633..412ddaf 100644 --- a/lib/search.js +++ b/lib/search.js @@ -9,8 +9,7 @@ scope = exports; } else { - window.scope.search = {}; - scope = window.scope.search; + scope = require.register("./search", {}); } const texts = []; diff --git a/lib/settingContainers.js b/lib/settingContainers.js index 30e5eed..ad9bfa5 100644 --- a/lib/settingContainers.js +++ b/lib/settingContainers.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.settingContainers = scope; + scope = require.register("./settingContainers", {}); } const logging = require("./logging"); diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js index 95b36fe..0586bdc 100644 --- a/lib/settingDefinitions.js +++ b/lib/settingDefinitions.js @@ -346,6 +346,6 @@ module.exports = settingDefinitions; } else { - window.scope.settingDefinitions = settingDefinitions; + require.register("./settingDefinitions", settingDefinitions); } }()); \ No newline at end of file diff --git a/lib/settingStrings.js b/lib/settingStrings.js index 32626fd..50d06a4 100644 --- a/lib/settingStrings.js +++ b/lib/settingStrings.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.settingStrings = scope; + scope = require.register("./settingStrings", {}); } scope.getMessages = function(settingDefinition){ diff --git a/lib/settings.js b/lib/settings.js index 803fe79..3d51425 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -(function(){ +(function(require){ "use strict"; var scope; @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.settings = scope; + scope = require.register("./settings", {}); } const logging = require("./logging"); @@ -428,8 +427,8 @@ initEvents.forEach(function(callback){callback();}); return true; }; - if (window.scope.settingsData){ - scope.init(window.scope.settingsData); + if (require.exists("./settingsData")){ + scope.init(require("./settingsData")); scope.loaded = Promise.resolve(false); } else { @@ -468,4 +467,4 @@ Object.seal(scope); require.emit("./settings"); -}()); \ No newline at end of file +}(require)); \ No newline at end of file diff --git a/lib/settingsMigration.js b/lib/settingsMigration.js index 00f4b95..4ec0213 100644 --- a/lib/settingsMigration.js +++ b/lib/settingsMigration.js @@ -10,8 +10,7 @@ scope = exports; } else { - window.scope.settingsMigration = {}; - scope = window.scope.settingsMigration; + scope = require.register("./settingsMigration", {}); } scope.validVersions = [undefined, 0.1, 0.2, 0.3, 0.4, 0.5]; scope.transitions = { diff --git a/lib/webgl.js b/lib/webgl.js index 3911f1f..8818b20 100644 --- a/lib/webgl.js +++ b/lib/webgl.js @@ -11,8 +11,7 @@ scope = exports; } else { - window.scope.webgl = {}; - scope = window.scope.webgl; + scope = require.register("./webgl", {}); } scope.copyCanvasToWebgl = function copyCanvasToWebgl(window, canvas, webGLVersion = "webgl"){ diff --git a/options/optionsGui.js b/options/optionsGui.js index 1b34127..8657bd3 100644 --- a/options/optionsGui.js +++ b/options/optionsGui.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.optionsGui = scope; + scope = require.register("./optionsGui", {}); } const logging = require("./logging"); diff --git a/options/sanitationRules.js b/options/sanitationRules.js index 844874b..4f802d6 100644 --- a/options/sanitationRules.js +++ b/options/sanitationRules.js @@ -9,8 +9,7 @@ scope = exports; } else { - scope = {}; - window.scope.sanitationRules = scope; + scope = require.register("./sanitationRules", {}); } const settings = require("./settings"); diff --git a/options/sanitize.js b/options/sanitize.js index 9ca2af3..3950a62 100644 --- a/options/sanitize.js +++ b/options/sanitize.js @@ -5,6 +5,7 @@ "use strict"; const settings = require("./settings"); + const sanitationRules = require("./sanitationRules"); var title = document.createElement("h1"); title.className = "title"; @@ -18,7 +19,6 @@ settings.onloaded(function(){ const list = document.createElement("ul"); - const sanitationRules = require("./sanitationRules"); sanitationRules.ruleset.forEach(function(ruleset){ const rulesetContainer = document.createElement("li"); rulesetContainer.textContent = browser.i18n.getMessage("sanitation_ruleset." + ruleset.name); diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 5fa594a..52a98bb 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -545,6 +545,6 @@ module.exports = settingsDisplay; } else { - window.scope.settingsDisplay = settingsDisplay; + require.register("./settingsDisplay", settingsDisplay); } }()); \ No newline at end of file diff --git a/pageAction/domainNotification.js b/pageAction/domainNotification.js index d96bab8..5611449 100644 --- a/pageAction/domainNotification.js +++ b/pageAction/domainNotification.js @@ -179,5 +179,5 @@ return domainNotification; }; domainNotification.addAction = addAction; - window.scope.domainNotification = domainNotification; + require.register("./domainNotification", domainNotification); }()); \ No newline at end of file diff --git a/pageAction/gui.js b/pageAction/gui.js index 0b9f0c1..4fdd382 100644 --- a/pageAction/gui.js +++ b/pageAction/gui.js @@ -5,7 +5,7 @@ (function(){ "use strict"; - const scope = window.scope.gui = {}; + const scope = require.register("./gui", {}); const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("./logging"); diff --git a/pageAction/notification.js b/pageAction/notification.js index 9f41158..409452b 100644 --- a/pageAction/notification.js +++ b/pageAction/notification.js @@ -72,5 +72,5 @@ update(){} } Notification.addAction = addAction; - window.scope.Notification = Notification; + require.register("./Notification", Notification); }()); \ No newline at end of file diff --git a/releaseNotes.txt b/releaseNotes.txt index 8946e5b..c1d9fae 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -1,6 +1,6 @@ Version 0.5.9: changes: - - + - code cleanup new features: - added protection for navigator properties