2015-09-08 11:41:33 +02:00
|
|
|
/* jslint moz: true */
|
2015-01-16 13:01:01 +01:00
|
|
|
/* 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/. */
|
2014-08-20 10:21:38 +02:00
|
|
|
(function(){
|
2014-10-14 01:06:11 +02:00
|
|
|
"use strict";
|
2015-06-23 13:14:50 +02:00
|
|
|
require("./stylePreferencePane");
|
2014-10-11 00:07:51 +02:00
|
|
|
|
2015-09-06 12:26:50 +02:00
|
|
|
|
2016-02-13 12:28:36 +01:00
|
|
|
const {when: unload} = require("sdk/system/unload");
|
2016-11-13 14:51:58 +01:00
|
|
|
const {check, checkStack} = require("./check.js");
|
2016-02-13 12:28:36 +01:00
|
|
|
const {notify} = require("./notifications");
|
|
|
|
|
|
|
|
const _ = require("sdk/l10n").get;
|
|
|
|
const lists = require("./lists");
|
2015-09-06 12:26:50 +02:00
|
|
|
const preferences = require("sdk/simple-prefs");
|
2016-02-13 12:28:36 +01:00
|
|
|
const prefService = require("sdk/preferences/service");
|
2015-09-06 12:26:50 +02:00
|
|
|
const prefs = preferences.prefs;
|
2014-12-15 18:43:47 +01:00
|
|
|
|
2016-02-13 12:28:36 +01:00
|
|
|
const notificationPref = {
|
|
|
|
doShow: function(){
|
|
|
|
return prefs.showNotifications;
|
|
|
|
},
|
|
|
|
setShow: function(value){
|
|
|
|
prefs.showNotifications = value;
|
|
|
|
prefService.set("extensions.CanvasBlocker@kkapsner.de.showNotifications", prefs.showNotifications);
|
2016-11-11 00:19:25 +01:00
|
|
|
},
|
|
|
|
displayTime: function(){
|
|
|
|
return prefs.notificationDisplayTime;
|
2015-09-06 15:40:34 +02:00
|
|
|
}
|
2016-02-13 12:28:36 +01:00
|
|
|
};
|
2015-04-24 01:04:14 +02:00
|
|
|
|
2016-02-13 12:28:36 +01:00
|
|
|
const {Cc, Ci} = require("chrome");
|
|
|
|
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
|
|
|
var frameURL = require("sdk/self").data.url("frame.js?" + Math.random());
|
|
|
|
globalMM.loadFrameScript(frameURL, true);
|
2015-09-06 12:26:50 +02:00
|
|
|
|
2016-02-13 12:28:36 +01:00
|
|
|
var listeners = [];
|
|
|
|
function addMessageListener(name, func){
|
|
|
|
listeners.push({name, func});
|
|
|
|
globalMM.addMessageListener(name, func);
|
|
|
|
}
|
2015-09-06 12:26:50 +02:00
|
|
|
unload(function(){
|
2016-02-13 12:28:36 +01:00
|
|
|
globalMM.removeDelayedFrameScript(frameURL);
|
|
|
|
globalMM.broadcastAsyncMessage("canvasBlocker-unload");
|
|
|
|
listeners.forEach(function(listener){
|
|
|
|
globalMM.removeMessageListener(listener.name, listener.func);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// messages from the frame.js
|
|
|
|
addMessageListener("canvasBlocker-check", function(ev){
|
|
|
|
var status = check(ev.data);
|
|
|
|
return status;
|
|
|
|
});
|
2016-11-13 14:51:58 +01:00
|
|
|
addMessageListener("canvasBlocker-checkStack", function(ev){
|
|
|
|
return checkStack(ev.data);
|
|
|
|
});
|
2016-02-13 12:28:36 +01:00
|
|
|
|
|
|
|
addMessageListener("canvasBlocker-notify", function(ev){
|
|
|
|
var browser = ev.target;
|
|
|
|
notify(ev.data, {lists, _, notificationPref, browser});
|
|
|
|
});
|
|
|
|
|
|
|
|
addMessageListener("canvasBlocker-pref-get", function(ev){
|
|
|
|
return prefs[ev.data];
|
|
|
|
});
|
|
|
|
addMessageListener("canvasBlocker-pref-set", function(ev){
|
|
|
|
prefs[ev.data.name] = ev.data.value;
|
|
|
|
prefService.set("extensions.CanvasBlocker@kkapsner.de." + ev.data.name, ev.data.value);
|
2014-08-20 10:21:38 +02:00
|
|
|
});
|
2016-02-13 12:28:36 +01:00
|
|
|
|
|
|
|
addMessageListener("canvasBlocker-list-match", function(ev){
|
|
|
|
return lists.get(ev.data.list).match(ev.data.url);
|
|
|
|
});
|
|
|
|
addMessageListener("canvasBlocker-list-appendTo", function(ev){
|
|
|
|
return lists.appendTo(ev.data.list, ev.data.entry);
|
|
|
|
});
|
|
|
|
|
|
|
|
addMessageListener("canvasBlocker-translate", function(ev){
|
|
|
|
return _(ev.data);
|
|
|
|
});
|
|
|
|
|
2016-11-13 15:34:33 +01:00
|
|
|
var data = require("sdk/self").data;
|
|
|
|
preferences.on("showReleaseNotes", function(){
|
|
|
|
var url = data.url("releaseNotes.txt").replace("/data/", "/");
|
|
|
|
require("sdk/tabs").open(url);
|
|
|
|
});
|
2014-08-20 10:21:38 +02:00
|
|
|
}());
|