mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Added pageAction to display the notifications.
This commit is contained in:
parent
cba5680406
commit
5cec9781c2
19
lib/frame.js
19
lib/frame.js
@ -36,10 +36,21 @@
|
|||||||
prefs
|
prefs
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var port = browser.runtime.connect();
|
||||||
|
var tabId;
|
||||||
|
port.onMessage.addListener(function(data){
|
||||||
|
if (data.hasOwnProperty("tabId")){
|
||||||
|
console.log("my tab id is", data.tabId);
|
||||||
|
tabId = data.tabId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var notifications = [];
|
||||||
function notify(data){
|
function notify(data){
|
||||||
browser.runtime.sendMessage({"canvasBlocker-notify": data});
|
notifications.push(data);
|
||||||
|
port.postMessage({"canvasBlocker-notify": data});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const preferences = require("sdk/simple-prefs");
|
const preferences = require("sdk/simple-prefs");
|
||||||
function prefs(name){
|
function prefs(name){
|
||||||
return preferences.prefs[name];
|
return preferences.prefs[name];
|
||||||
@ -99,5 +110,11 @@
|
|||||||
if (data["canvasBlocker-unload"]){
|
if (data["canvasBlocker-unload"]){
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
if (data["canvasBlocker-sendNotifications"] === tabId){
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
sender: tabId,
|
||||||
|
"canvasBlocker-notifications": notifications
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
@ -81,7 +81,7 @@
|
|||||||
case "fake":
|
case "fake":
|
||||||
setRandomSupplyByType(prefs("rng"));
|
setRandomSupplyByType(prefs("rng"));
|
||||||
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
|
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
|
||||||
notify({url, errorStack: error.stack, messageId});
|
notify({url, errorStack: error.stack, messageId, timestamp: new Date()});
|
||||||
}, window, original);
|
}, window, original);
|
||||||
switch (fake){
|
switch (fake){
|
||||||
case true:
|
case true:
|
||||||
|
@ -10,8 +10,14 @@
|
|||||||
console.log("got data", data);
|
console.log("got data", data);
|
||||||
});
|
});
|
||||||
browser.runtime.onConnect.addListener(function(port){
|
browser.runtime.onConnect.addListener(function(port){
|
||||||
console.log("got port");
|
console.log("got port", port);
|
||||||
|
port.postMessage({tabId: port.sender.tab.id});
|
||||||
|
port.onMessage.addListener(function(data){
|
||||||
|
browser.pageAction.show(port.sender.tab.id);
|
||||||
|
console.log("got data", data, "from port", port);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("end main script");
|
console.log("end main script");
|
||||||
return null;
|
return null;
|
||||||
require("./stylePreferencePane");
|
require("./stylePreferencePane");
|
||||||
|
@ -34,6 +34,14 @@
|
|||||||
"browser_style": true,
|
"browser_style": true,
|
||||||
"page": "options/options.html"
|
"page": "options/options.html"
|
||||||
},
|
},
|
||||||
|
"page_action": {
|
||||||
|
"browser_style": true,
|
||||||
|
"default_icon": {
|
||||||
|
"19": "pageAction/printed19.png",
|
||||||
|
"38": "pageAction/printed38.png"
|
||||||
|
},
|
||||||
|
"default_popup": "pageAction/pageAction.html"
|
||||||
|
},
|
||||||
"author": "Korbinian Kapsner",
|
"author": "Korbinian Kapsner",
|
||||||
"license": "MPL 2.0",
|
"license": "MPL 2.0",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
10
pageAction/pageAction.css
Normal file
10
pageAction/pageAction.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.template {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#prints {
|
||||||
|
min-width: 400px;
|
||||||
|
}
|
||||||
|
.print {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
12
pageAction/pageAction.html
Normal file
12
pageAction/pageAction.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>CanvasBlocker page action</title>
|
||||||
|
<link href="pageAction.css" rel="stylesheet" type="text/css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul id="prints">
|
||||||
|
</ul>
|
||||||
|
<script src="pageAction.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
pageAction/pageAction.js
Normal file
26
pageAction/pageAction.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// console.log(window, browser, browser.runtime);
|
||||||
|
browser.tabs.query({active: true, currentWindow: true}).then(function(tabs){
|
||||||
|
if (!tabs.length){
|
||||||
|
throw new Error("noTabsFound");
|
||||||
|
}
|
||||||
|
var tab = tabs[0];
|
||||||
|
browser.runtime.onMessage.addListener(function(data){
|
||||||
|
if (Array.isArray(data["canvasBlocker-notifications"])){
|
||||||
|
var ul = document.getElementById("prints");
|
||||||
|
data["canvasBlocker-notifications"].forEach(function(notification){
|
||||||
|
var li = document.createElement("li");
|
||||||
|
li.className = "print";
|
||||||
|
li.textContent = notification.url + ": " + notification.messageId + " (" + notification.timestamp + ")" + "\n" + notification.errorStack;
|
||||||
|
ul.appendChild(li);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
browser.tabs.sendMessage(
|
||||||
|
tab.id,
|
||||||
|
{
|
||||||
|
"canvasBlocker-sendNotifications": tab.id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}).catch(function(e){
|
||||||
|
console.error(e);
|
||||||
|
});
|
BIN
pageAction/printed19.png
Normal file
BIN
pageAction/printed19.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
pageAction/printed38.png
Normal file
BIN
pageAction/printed38.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
@ -2,8 +2,10 @@ Version 0.4.0:
|
|||||||
todos:
|
todos:
|
||||||
- import settings in content script (have to wait for the new API to register content scripts)
|
- import settings in content script (have to wait for the new API to register content scripts)
|
||||||
- check if webGL is still working
|
- check if webGL is still working
|
||||||
|
- add notification actions to page action popup
|
||||||
changes:
|
changes:
|
||||||
- switched to webExtension
|
- switched to webExtension
|
||||||
|
- notifications are now done via page action
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
-
|
-
|
||||||
|
Loading…
x
Reference in New Issue
Block a user