1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Removed memory leak

This commit is contained in:
kkapsner 2014-10-04 14:26:05 +02:00
parent 40d059311a
commit 70a16e55a6
3 changed files with 23 additions and 18 deletions

Binary file not shown.

View File

@ -37,6 +37,10 @@
var oldBorder = this.style.border;
this.style.border = "2px dashed red";
var confirmText = "askForPermission";
// try {throw new Error();}
// catch (e){
// console.log(e.stack.split(/\s*(?:-?>|@)\s*/));
// }
var allow = confirm(confirmText);
this.style.border = oldBorder;
if (allow){

View File

@ -55,7 +55,7 @@
updateWhiteList();
preferences.on("whiteList", function(){
updateWhiteList();
workers.forEach(checkWorker);
// workers.forEach(checkWorker);
});
var blackList;
@ -65,23 +65,24 @@
updateBlackList();
preferences.on("blackList", function(){
updateBlackList();
workers.forEach(checkWorker);
// workers.forEach(checkWorker);
});
preferences.on("blockMode", function(){
workers.forEach(checkWorker);
});preferences.on("allowPDFCanvas", function(){
workers.forEach(checkWorker);
});
// preferences.on("blockMode", function(){
// workers.forEach(checkWorker);
// });
// preferences.on("allowPDFCanvas", function(){
// workers.forEach(checkWorker);
// });
var workers = [];
function detachWorker(worker, workerArray) {
var index = workerArray.indexOf(worker);
if (index != -1){
workerArray.splice(index, 1);
}
}
// var workers = [];
// function detachWorker(worker, workerArray) {
// var index = workerArray.indexOf(worker);
// if (index !== -1){
// workerArray.splice(index, 1);
// }
// }
function checkWorker(worker){
var url = new URL(worker.url);
switch (prefs.blockMode){
@ -141,10 +142,10 @@
contentScriptFile: self.data.url("inject.js"),
onAttach: function(worker){
workers.push(worker);
worker.on("detach", function(){
detachWorker(this, workers);
});
// workers.push(worker);
// worker.on("detach", function(){
// detachWorker(this, workers);
// });
worker.port.on("isPDF", function(blocking){
if (prefs.allowPDFCanvas){
worker.port.emit("unblock");