mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-22 03:18:31 +01:00
First notification steps - NOT FUNCTIONAL!
This commit is contained in:
parent
4bcdfb9fb7
commit
0a88d47609
@ -10,6 +10,7 @@
|
||||
};
|
||||
var blockMode = {
|
||||
getContext: {
|
||||
name: "getContext",
|
||||
status: "block",
|
||||
askText: {
|
||||
visible: "askForVisiblePermission",
|
||||
@ -23,6 +24,7 @@
|
||||
}
|
||||
},
|
||||
readAPI: {
|
||||
name: "readAPI",
|
||||
status: "allow",
|
||||
askText: {
|
||||
visible: "askForVisibleReadoutPermission",
|
||||
@ -196,6 +198,7 @@
|
||||
appearance.reset();
|
||||
}
|
||||
}
|
||||
self.port.emit("accessed " + changedFunction.mode.name, status);
|
||||
switch (status){
|
||||
case "allow":
|
||||
return original;
|
||||
@ -242,7 +245,7 @@
|
||||
// Communication with main.js
|
||||
|
||||
function checkAbout(){
|
||||
return document.location.protocol === "about:");
|
||||
return document.location.protocol === "about:";
|
||||
}
|
||||
|
||||
function checkPDF(blocking){
|
||||
|
53
lib/main.js
53
lib/main.js
@ -48,6 +48,7 @@
|
||||
var pageMod = require("sdk/page-mod");
|
||||
var array = require("sdk/util/array");
|
||||
var preferences = require("sdk/simple-prefs");
|
||||
var prefService = require("sdk/preferences/service");
|
||||
var prefs = preferences.prefs;
|
||||
var URL = require("sdk/url").URL;
|
||||
var _ = require("sdk/l10n").get;
|
||||
@ -87,7 +88,7 @@
|
||||
});
|
||||
|
||||
function checkURL(url){
|
||||
var url = new URL(url);
|
||||
url = new URL(url);
|
||||
var mode = "block";
|
||||
switch (prefs.blockMode){
|
||||
case "blockEverything":
|
||||
@ -180,6 +181,56 @@
|
||||
});
|
||||
|
||||
checkWorker(worker);
|
||||
|
||||
// display notifications
|
||||
worker.port.on("accessed readAPI", function(status){
|
||||
switch (status){
|
||||
case "fake":
|
||||
var contentURL = new URL(worker.contentURL);
|
||||
var url = contentURL.href;
|
||||
var domain = contentURL.hostname;
|
||||
var message = "Faked readout on " + url;
|
||||
|
||||
|
||||
var notifyBox = gWindow.getNotificationBox();
|
||||
var notification = notifiyBox.getNotificationBoxWithValue("fake-readout");
|
||||
if (notification){
|
||||
notification.label = message;
|
||||
}
|
||||
else {
|
||||
var buttons = [
|
||||
{
|
||||
label: 'whitelist URL',
|
||||
callback: function(){
|
||||
prefs.whiteList += "," + url;
|
||||
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
|
||||
updateWhiteList();
|
||||
workers.forEach(checkWorker);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'whitelist domain',
|
||||
callback: function(){
|
||||
prefs.whiteList += "," + domain;
|
||||
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
|
||||
updateWhiteList();
|
||||
workers.forEach(checkWorker);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
let priority = box.PRIORITY_WARNING_MEDIUM;
|
||||
box.appendNotification(
|
||||
message,
|
||||
'fake-readout',
|
||||
'chrome://browser/skin/Info.png',
|
||||
priority,
|
||||
buttons
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
"name": "blockMode",
|
||||
"title": "block mode",
|
||||
"type": "menulist",
|
||||
"value": "askReadout",
|
||||
"value": "fakeReadout",
|
||||
"options": [
|
||||
{
|
||||
"value": "blockEverything",
|
||||
|
Loading…
x
Reference in New Issue
Block a user