1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-06-13 16:39:52 +02:00
CanvasBlocker/lib/main.js

61 lines
1.9 KiB
JavaScript
Raw Normal View History

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";
require("./stylePreferencePane");
2014-10-11 00:07:51 +02:00
2016-02-13 12:28:36 +01:00
const {when: unload} = require("sdk/system/unload");
const {notify} = require("./notifications");
const _ = require("sdk/l10n").get;
const lists = require("./lists");
const preferences = require("sdk/simple-prefs");
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);
},
displayTime: function(){
return prefs.notificationDisplayTime;
}
2016-02-13 12:28:36 +01:00
};
2015-04-24 01:04:14 +02:00
const {processes, frames, remoteRequire} = require("sdk/remote/parent");
remoteRequire("./frame.js", module);
frames.port.on("canvasBlocker-notify", function(frame, data){
notify(data, {lists, _, notificationPref, browser: frame.frameElement});
2016-02-13 12:28:36 +01:00
});
unload(function(){
processes.port.emit("canvasBlocker-unload");
2016-02-13 12:28:36 +01:00
});
// persistent rng
const persistentRnd = Object.create(null);
processes.port.on("canvasBlocker-new-domain-rnd", function(process, data){
processes.port.emit("canvasBlocker-set-domain-rnd", data);
persistentRnd[data.domain] = data.rnd;
});
processes.on("attach", function(process){
if (process.isRemote){
for (var name in persistentRnd){
process.port.emit("canvasBlocker-set-domain-rnd", {domain: name, rnd: persistentRnd[name]});
}
}
});
// show release notes
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
}());