Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
changed window assignments to this in the content-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Apr 12, 2017
1 parent 274cce9 commit ecd301b
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 26 deletions.
3 changes: 2 additions & 1 deletion addon/webextension/assertIsTrusted.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted
Should be applied *inside* catcher.watchFunction
*/
function assertIsTrusted(handlerFunction) {
this.assertIsTrusted = function assertIsTrusted(handlerFunction) {
return function (event) {
if (! event) {
let exc = new Error("assertIsTrusted did not get an event");
Expand All @@ -17,3 +17,4 @@ function assertIsTrusted(handlerFunction) {
return handlerFunction.call(this, event);
};
}
null;
2 changes: 1 addition & 1 deletion addon/webextension/background/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.analytics = (function () {
this.analytics = (function () {
let exports = {};

let telemetryPrefKnown = false;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

window.auth = (function () {
this.auth = (function () {
let exports = {};

let registrationInfo;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.communication = (function () {
this.communication = (function () {
let exports = {};

let registeredFunctions = {};
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/deviceInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.deviceInfo = (function () {
this.deviceInfo = (function () {
let manifest = browser.runtime.getManifest();

let platformInfo = {};
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

window.main = (function () {
this.main = (function () {
let exports = {};

const pasteSymbol = (window.navigator.platform.match(/Mac/i)) ? "\u2318" : "Ctrl";
Expand Down
10 changes: 5 additions & 5 deletions addon/webextension/background/selectorLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.selectorLoader = (function () {
this.selectorLoader = (function () {
const exports = {};

// These modules are loaded in order, first standardScripts, then optionally onboardingScripts, and then selectorScripts
Expand Down Expand Up @@ -37,10 +37,10 @@ window.selectorLoader = (function () {

exports.unloadIfLoaded = function (tabId) {
return browser.tabs.executeScript(tabId, {
code: "window.selectorLoader && window.selectorLoader.unloadModules()",
code: "this.selectorLoader && this.selectorLoader.unloadModules()",
runAt: "document_start"
}).then(result => {
return result && result.toString() === "true";
return result && result[0];
});
};

Expand Down Expand Up @@ -84,15 +84,15 @@ window.selectorLoader = (function () {
filename.replace(/^.*\//, "").replace(/\.js$/, ""));
moduleNames.reverse();
for (let moduleName of moduleNames) {
let moduleObj = window[moduleName];
let moduleObj = global[moduleName];
if (moduleObj && moduleObj.unload) {
try {
watchFunction(moduleObj.unload)();
} catch (e) {
// ignore (watchFunction handles it)
}
}
delete window[moduleName];
delete global[moduleName];
}
return true;
};
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/senderror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.senderror = (function () {
this.senderror = (function () {
let exports = {};

// Do not show an error more than every ERROR_TIME_LIMIT milliseconds:
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/takeshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.takeshot = (function () {
this.takeshot = (function () {
let exports = {};
const Shot = shot.AbstractShot;
const { sendEvent } = analytics;
Expand Down
4 changes: 3 additions & 1 deletion addon/webextension/catcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";

window.catcher = (function () {
var global = this;

this.catcher = (function () {
let exports = {};

let handler;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.clipboard = (function () {
this.clipboard = (function () {
let exports = {};

exports.copy = function (text) {
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/domainFromUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"use strict";

window.domainFromUrl = (function () {
this.domainFromUrl = (function () {

return function urlDomainForId(location) { // eslint-disable-line no-unused-vars
let domain = location.hostname;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/makeUuid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

window.makeUuid = (function () {
this.makeUuid = (function () {

// generates a v4 UUID
return function makeUuid() { // eslint-disable-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/onboarding/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

window.slides = (function () {
this.slides = (function () {
let exports = {};

const { watchFunction } = catcher;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/randomString.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

function randomString(length, chars) {
this.randomString = function randomString(length, chars) {
let randomStringChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
chars = chars || randomStringChars;
let result = "";
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/callBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

function callBackground (funcName, ...args) {
this.callBackground = function callBackground (funcName, ...args) {
return browser.runtime.sendMessage({funcName, args}).then((result) => {
if (result.type === "success") {
return result.value;
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/documentMetadata.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

window.documentMetadata = (function () {
this.documentMetadata = (function () {

function findSiteName() {
let el = document.querySelector("meta[property='og:site_name']");
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"use strict";

window.shooter = (function () { // eslint-disable-line no-unused-vars
this.shooter = (function () { // eslint-disable-line no-unused-vars
let exports = {};
const { AbstractShot } = window.shot;

Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

window.ui = (function () { // eslint-disable-line no-unused-vars
this.ui = (function () { // eslint-disable-line no-unused-vars
let exports = {};
const SAVE_BUTTON_HEIGHT = 50;

Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/uicontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

window.uicontrol = (function () {
this.uicontrol = (function () {
let exports = {};

/**********************************************************
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

window.util = (function () { // eslint-disable-line no-unused-vars
this.util = (function () { // eslint-disable-line no-unused-vars
let exports = {};

/** Removes a node from its document, if it's a node and the node is attached to a parent */
Expand Down
3 changes: 2 additions & 1 deletion addon/webextension/sitehelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"use strict";

window.sitehelper = (function () {
this.sitehelper = (function () {

catcher.registerHandler((errorObj) => {
callBackground("reportError", errorObj);
Expand Down Expand Up @@ -40,3 +40,4 @@ window.sitehelper = (function () {
sendCustomEvent("addon-present");

})();
null;

0 comments on commit ecd301b

Please sign in to comment.