1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Linted all files.

This commit is contained in:
kkapsner 2015-09-08 11:42:32 +02:00
parent 6c46d28593
commit 0904d8e2a6
6 changed files with 31 additions and 10 deletions

Binary file not shown.

View File

@ -56,9 +56,13 @@ var lists = {
}; };
function updateList(type){ function updateList(type){
"use strict";
lists[type] = getDomainRegExpList(prefs[type + "List"]); lists[type] = getDomainRegExpList(prefs[type + "List"]);
} }
Object.keys(lists).forEach(function(type){ Object.keys(lists).forEach(function(type){
"use strict";
preferences.on(type + "List", function(){ preferences.on(type + "List", function(){
updateList(type); updateList(type);
}); });
@ -66,11 +70,15 @@ Object.keys(lists).forEach(function(type){
}); });
exports.get = function getList(type){ exports.get = function getList(type){
"use strict";
return lists[type]; return lists[type];
} };
exports.appendTo = function appendToList(type, entry){ exports.appendTo = function appendToList(type, entry){
"use strict";
prefs[type + "List"] += (prefs[type + "List"]? ",": "") + entry; prefs[type + "List"] += (prefs[type + "List"]? ",": "") + entry;
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs[type + "List"]); prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs[type + "List"]);
updateList(type); updateList(type);
} };
exports.update = updateList; exports.update = updateList;

View File

@ -1,3 +1,4 @@
/* jslint moz: true, bitwise: true */
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -32,7 +33,7 @@
data[i] = value; data[i] = value;
} }
var canvas = original.cloneNode(true); var canvas = original.cloneNode(true);
var context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d"); context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
context.putImageData(imageData, 0, 0); context.putImageData(imageData, 0, 0);
return canvas; return canvas;
} }

View File

@ -7,11 +7,12 @@ var preferences = require("sdk/simple-prefs");
var prefService = require("sdk/preferences/service"); var prefService = require("sdk/preferences/service");
var prefs = preferences.prefs; var prefs = preferences.prefs;
var tabUtils = require("sdk/tabs/utils"); var tabUtils = require("sdk/tabs/utils");
var windowUtils = require("sdk/window/utils");
var lists = require("./lists"); var lists = require("./lists");
var URL = require("sdk/url").URL; var URL = require("sdk/url").URL;
exports.notify = function(window, callingStackMsg){ exports.notify = function(window, callingStackMsg){
"use strict";
var contentURL = new URL(window.location); var contentURL = new URL(window.location);
if (prefs.showNotifications && !lists.get("ignore").match(contentURL)){ if (prefs.showNotifications && !lists.get("ignore").match(contentURL)){
var url = contentURL.href; var url = contentURL.href;
@ -94,5 +95,4 @@ exports.notify = function(window, callingStackMsg){
notification.callingStackMsg = callingStackMsg; notification.callingStackMsg = callingStackMsg;
} }
} }
}; };

View File

@ -1,4 +1,5 @@
/* global console,exports */ /* global console,exports */
/* jslint moz: true */
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -10,6 +11,8 @@ const prefs = preferences.prefs;
// Translation // Translation
var translate = require("sdk/l10n").get; var translate = require("sdk/l10n").get;
var _ = function(name, replace){ var _ = function(name, replace){
"use strict";
var str = translate(name) || name; var str = translate(name) || name;
if (replace){ if (replace){
// replace generic content in the transation by given parameter // replace generic content in the transation by given parameter
@ -23,7 +26,8 @@ var _ = function(name, replace){
function checkURL(url, blockMode){ function checkURL(url, blockMode){
"use strict"; "use strict";
if (url.protocol === "about:" || url.protocol == "chrome:") {
if (url.protocol === "about:" || url.protocol === "chrome:") {
return "allow"; return "allow";
} }
@ -35,6 +39,9 @@ function checkURL(url, blockMode){
case "block": case "block":
case "blockContext": case "blockContext":
case "blockReadout": case "blockReadout":
case "ask":
case "askContext":
case "askReadout":
case "fake": case "fake":
case "fakeContext": case "fakeContext":
case "fakeReadout": case "fakeReadout":
@ -63,6 +70,8 @@ function checkURL(url, blockMode){
// Stack parsing // Stack parsing
function parseStackEntry(entry){ function parseStackEntry(entry){
"use strict";
var m = /@(.*):(\d*):(\d*)$/.exec(entry) || ["", entry, "--", "--"]; var m = /@(.*):(\d*):(\d*)$/.exec(entry) || ["", entry, "--", "--"];
return { return {
url: m[1], url: m[1],
@ -74,6 +83,8 @@ function parseStackEntry(entry){
// parse calling stack // parse calling stack
function errorToCallingStackMsg(error){ function errorToCallingStackMsg(error){
"use strict";
var msg = ""; var msg = "";
var callers = error.stack.trim().split("\n"); var callers = error.stack.trim().split("\n");
//console.log(callers); //console.log(callers);

View File

@ -1,16 +1,17 @@
/* jslint moz: true */
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){ (function(){
"use strict"; "use strict";
const { Cu } = require('chrome'); const { Cu } = require("chrome");
const { on } = require('sdk/system/events'); const { on } = require("sdk/system/events");
const self = require('sdk/self'); const self = require("sdk/self");
const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm"); const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
const { setTimeout } = require("sdk/timers"); const { setTimeout } = require("sdk/timers");
const { loadSheet } = require("sdk/stylesheet/utils"); const { loadSheet } = require("sdk/stylesheet/utils");
AddonManager.getAddonByID(self.id, function(addon){ AddonManager.getAddonByID(self.id, function(addon){
on('addon-options-displayed', onAddonOptionsDisplayed, true); on("addon-options-displayed", onAddonOptionsDisplayed, true);
}); });
function onAddonOptionsDisplayed({ subject: doc, data }) { function onAddonOptionsDisplayed({ subject: doc, data }) {