mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-23 05:10:27 +01:00
Removed memory leak
This commit is contained in:
parent
40d059311a
commit
70a16e55a6
Binary file not shown.
@ -37,6 +37,10 @@
|
|||||||
var oldBorder = this.style.border;
|
var oldBorder = this.style.border;
|
||||||
this.style.border = "2px dashed red";
|
this.style.border = "2px dashed red";
|
||||||
var confirmText = "askForPermission";
|
var confirmText = "askForPermission";
|
||||||
|
// try {throw new Error();}
|
||||||
|
// catch (e){
|
||||||
|
// console.log(e.stack.split(/\s*(?:-?>|@)\s*/));
|
||||||
|
// }
|
||||||
var allow = confirm(confirmText);
|
var allow = confirm(confirmText);
|
||||||
this.style.border = oldBorder;
|
this.style.border = oldBorder;
|
||||||
if (allow){
|
if (allow){
|
||||||
|
37
lib/main.js
37
lib/main.js
@ -55,7 +55,7 @@
|
|||||||
updateWhiteList();
|
updateWhiteList();
|
||||||
preferences.on("whiteList", function(){
|
preferences.on("whiteList", function(){
|
||||||
updateWhiteList();
|
updateWhiteList();
|
||||||
workers.forEach(checkWorker);
|
// workers.forEach(checkWorker);
|
||||||
});
|
});
|
||||||
|
|
||||||
var blackList;
|
var blackList;
|
||||||
@ -65,23 +65,24 @@
|
|||||||
updateBlackList();
|
updateBlackList();
|
||||||
preferences.on("blackList", function(){
|
preferences.on("blackList", function(){
|
||||||
updateBlackList();
|
updateBlackList();
|
||||||
workers.forEach(checkWorker);
|
// workers.forEach(checkWorker);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
preferences.on("blockMode", function(){
|
// preferences.on("blockMode", function(){
|
||||||
workers.forEach(checkWorker);
|
// workers.forEach(checkWorker);
|
||||||
});preferences.on("allowPDFCanvas", function(){
|
// });
|
||||||
workers.forEach(checkWorker);
|
// preferences.on("allowPDFCanvas", function(){
|
||||||
});
|
// workers.forEach(checkWorker);
|
||||||
|
// });
|
||||||
|
|
||||||
var workers = [];
|
// var workers = [];
|
||||||
function detachWorker(worker, workerArray) {
|
// function detachWorker(worker, workerArray) {
|
||||||
var index = workerArray.indexOf(worker);
|
// var index = workerArray.indexOf(worker);
|
||||||
if (index != -1){
|
// if (index !== -1){
|
||||||
workerArray.splice(index, 1);
|
// workerArray.splice(index, 1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
function checkWorker(worker){
|
function checkWorker(worker){
|
||||||
var url = new URL(worker.url);
|
var url = new URL(worker.url);
|
||||||
switch (prefs.blockMode){
|
switch (prefs.blockMode){
|
||||||
@ -141,10 +142,10 @@
|
|||||||
contentScriptFile: self.data.url("inject.js"),
|
contentScriptFile: self.data.url("inject.js"),
|
||||||
onAttach: function(worker){
|
onAttach: function(worker){
|
||||||
|
|
||||||
workers.push(worker);
|
// workers.push(worker);
|
||||||
worker.on("detach", function(){
|
// worker.on("detach", function(){
|
||||||
detachWorker(this, workers);
|
// detachWorker(this, workers);
|
||||||
});
|
// });
|
||||||
worker.port.on("isPDF", function(blocking){
|
worker.port.on("isPDF", function(blocking){
|
||||||
if (prefs.allowPDFCanvas){
|
if (prefs.allowPDFCanvas){
|
||||||
worker.port.emit("unblock");
|
worker.port.emit("unblock");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user