From 5cec9781c2be987f07f2b3707866e78c83b036e4 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Thu, 29 Jun 2017 07:21:36 +0200 Subject: [PATCH] Added pageAction to display the notifications. --- lib/frame.js | 19 ++++++++++++++++++- lib/intercept.js | 2 +- lib/main.js | 8 +++++++- manifest.json | 8 ++++++++ pageAction/pageAction.css | 10 ++++++++++ pageAction/pageAction.html | 12 ++++++++++++ pageAction/pageAction.js | 26 ++++++++++++++++++++++++++ pageAction/printed19.png | Bin 0 -> 1125 bytes pageAction/printed38.png | Bin 0 -> 3766 bytes releaseNotes.txt | 2 ++ 10 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 pageAction/pageAction.css create mode 100644 pageAction/pageAction.html create mode 100644 pageAction/pageAction.js create mode 100644 pageAction/printed19.png create mode 100644 pageAction/printed38.png diff --git a/lib/frame.js b/lib/frame.js index f6dc2e2..6e72fe4 100644 --- a/lib/frame.js +++ b/lib/frame.js @@ -36,10 +36,21 @@ 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){ - browser.runtime.sendMessage({"canvasBlocker-notify": data}); + notifications.push(data); + port.postMessage({"canvasBlocker-notify": data}); } + const preferences = require("sdk/simple-prefs"); function prefs(name){ return preferences.prefs[name]; @@ -99,5 +110,11 @@ if (data["canvasBlocker-unload"]){ enabled = false; } + if (data["canvasBlocker-sendNotifications"] === tabId){ + browser.runtime.sendMessage({ + sender: tabId, + "canvasBlocker-notifications": notifications + }); + } }); }()); \ No newline at end of file diff --git a/lib/intercept.js b/lib/intercept.js index 91cd0ef..bf18cd4 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -81,7 +81,7 @@ case "fake": setRandomSupplyByType(prefs("rng")); var fake = changedFunction.fakeGenerator(prefs, function(messageId){ - notify({url, errorStack: error.stack, messageId}); + notify({url, errorStack: error.stack, messageId, timestamp: new Date()}); }, window, original); switch (fake){ case true: diff --git a/lib/main.js b/lib/main.js index 549db09..0b8551b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -10,8 +10,14 @@ console.log("got data", data); }); 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"); return null; require("./stylePreferencePane"); diff --git a/manifest.json b/manifest.json index 01c2a81..ce6488d 100644 --- a/manifest.json +++ b/manifest.json @@ -34,6 +34,14 @@ "browser_style": true, "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", "license": "MPL 2.0", "permissions": [ diff --git a/pageAction/pageAction.css b/pageAction/pageAction.css new file mode 100644 index 0000000..eb9bcb4 --- /dev/null +++ b/pageAction/pageAction.css @@ -0,0 +1,10 @@ +.template { + display: none; +} + +#prints { + min-width: 400px; +} +.print { + white-space: pre; +} \ No newline at end of file diff --git a/pageAction/pageAction.html b/pageAction/pageAction.html new file mode 100644 index 0000000..0dc3c84 --- /dev/null +++ b/pageAction/pageAction.html @@ -0,0 +1,12 @@ + + + + CanvasBlocker page action + + + + + + + diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js new file mode 100644 index 0000000..9bfa3ba --- /dev/null +++ b/pageAction/pageAction.js @@ -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); +}); \ No newline at end of file diff --git a/pageAction/printed19.png b/pageAction/printed19.png new file mode 100644 index 0000000000000000000000000000000000000000..47f97c0d7246111124e4cd080e15f720e92900eb GIT binary patch literal 1125 zcmV-r1e*JaP)z1A*NvGXze|YE4o%Lq3SzwF}eBb}>(W6H3|81w!`Rt9b-QC@HZr;54g<%-)Ynq1HY=+rvhGMaZ zD2iZN7J?waVzEFR#~;bB16{dt<{i94NsmtK{lHO02B%Z2qECQE*N8n z3dZs)WJ#7~eKMU+uQeKtrBbPc{r!F9aybYgkR%Bl$3Z@yN0KBc6bdj514)uN|AMWo ztb8z?POl$3c1+G>GMG#z=yW;|LO_;fgkgxKr6s7U3dR_oK79&82=e*-!QWup+uNre zJb3U!nx@3}eR!USQmF*jbs>a+<2Z<-2<37aaU6qlj!LBh-}jNG>5s}GXk%kz`TqU; z*D95YQY;psC@)r{(Fj2hKnMZG7;M|dY&L`Ix=>XWnx;Y5b;NP}>mf{9Utj-{5Ym{> z=a@_;@O>YOqQEpwsHzIj^U&#Z(C_zg4Ng`_OeAk|bfVSm5Zc&Y2ch=JRZaIJTS(<7(*C_ux%T6@7~2>qzECSlP6DZ z9GXaWcXv;5&JhFwy4^0GKYtEYRlzxb>7Z$vh~pTe(Fm4hVLqS3vaEDC9G>cSyWvaN z@#DwarBVrt#R7(5fKm$2^N`EspePC|l?piL&@>H|N(G+hA)n7jwr!uieEIVJU;mVZ zVW{MCIq13$-}f;dkCDx0A%uXg>j=XahY2B&BngyKW*Ek~)2B~g|7UuLX_~*qag2Js zjvxrIy1EL+80PaiD5ZGz>=_hA0i_hn%ge51S-mr7&Rly{IS@+eH3e! ztJM(4F=SarHk$?K9PM^{N7J-!uh;wObxk8vN`I%6HeJ_UA%sZN=@dzlpw((2lgWgQ rM&pmQwYASroH%iAb92*wQ~&)5yE@wY#dn+>00000NkvXXu0mjf9ta93 literal 0 HcmV?d00001 diff --git a/pageAction/printed38.png b/pageAction/printed38.png new file mode 100644 index 0000000000000000000000000000000000000000..2fd73683b8cc71822de72c1f11db65fe9c0160e9 GIT binary patch literal 3766 zcmWkx2{=^y8&+H-%Y+o^PYj8|Ws;PA#@5*P$re(iFqR^5OVW^JCNbHpc7e((Dpf`yqOACDLh8yg#+u@Tw|_Og2$Hz#}- zXigWwj??{;A)0M>@AHbDPl7WC{EZv~;Rn^dZQmB%TmnvV1sR)SxW;%79}zel7gy=Z z#>TI2jMlYrXsSrr@JkKOV7MmCG3?zLl!>=3Ma~zzU!saqb1Vb}!zA6h=T5m{svo}S z6CGmX}@{l5&0nN=Mz*8#XLP?OpFxI1>L&7mN3b!BJh#o2udIkm@wbj+vXBQX!3vtvC?+P4B zjPKyVgThCSOoY@D&{9||)(s_gfHO*6od4Ix#pUJYdrI|xensda@*+)?w;Q6kB1H-4 z9j}p^;O0aljtZQqR^~}EHoMoyvapwzm)Am0xPVH{t*cA(SI4TQUJVHmNoF+@gigvn zmC$xsx)zmwG1Q9EJsl#K)K;~*wbemD?=Kr@|MTZ!gB!w_SWr;Frb9%&NKWpW4&sQ? z{W&v3PEVIP%3FG+iBr*~uJsG`GIJ7NA2D{HD`Th2t@GmYljZRkiJj)92}Y)oEUBlb zXR+7bm3DJTO)8OFJ}LI=R~JteQHl*u*}#*gakrqL=XWkXWlWq9<{9@_|8HS|F&7dz z(Za`}``Ei;aOIZ-dy+}+yi9GvA_T5%F0Tqehk0!R>PsYGt{d2 znYlU5mmOZs(b0e5tHp;ZZ#GRVz3RGdL9q$CeVfGegoD$Hih{hH1ND*G$%@W;xmG8P z1!ZJp(lml&=Z2~#*0!K6fQ*KQ22ZEv+Hi3MqCZPNX6F=wTU;1(DBaBP>Qx#3m?#S6 z)c*TyUDu!ct3QEfC1Z(9&(^8s=g*%%GeSOQOdO3jcy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