mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Big linting
This commit is contained in:
parent
b5e6d049ce
commit
aef6bd3d59
58 changed files with 2074 additions and 1856 deletions
|
@ -4,7 +4,7 @@
|
|||
(function(){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
|||
const rngTemplate = {
|
||||
getBitRng: function(length, window){
|
||||
const rng = this.getRng(Math.ceil(length / 32), window);
|
||||
let bitIndex = 32;
|
||||
let rnd = 0;
|
||||
let mask = 0xffffffff * 2;
|
||||
return function(value, i){
|
||||
|
@ -38,20 +37,21 @@
|
|||
getValueRng: function(length, window){
|
||||
const rng = this.getBitRng(length, window);
|
||||
return function(value, i){
|
||||
var rnd = rng(value, i);
|
||||
const rnd = rng(value, i);
|
||||
|
||||
// XOR the last bit to alter it... or not
|
||||
return value ^ (rnd & 0x01);
|
||||
};
|
||||
},
|
||||
getPixelRng: function(length, window, ignoredColors){
|
||||
var rng = this.getValueRng(length, window);
|
||||
return function(r, g, b, a, i){ // eslint-disable-line max-params
|
||||
var index = String.fromCharCode(r, g, b, a);
|
||||
const rng = this.getValueRng(length, window);
|
||||
// eslint-disable-next-line max-params
|
||||
return function(r, g, b, a, i){
|
||||
const index = String.fromCharCode(r, g, b, a);
|
||||
if (ignoredColors[index]){
|
||||
return [r, g, b, a];
|
||||
}
|
||||
var baseIndex = i * 4;
|
||||
const baseIndex = i * 4;
|
||||
return [
|
||||
rng(r, baseIndex + 0),
|
||||
rng(g, baseIndex + 1),
|
||||
|
@ -81,7 +81,7 @@
|
|||
return window.location.host;
|
||||
}
|
||||
|
||||
var persistentRnd = Object.create(null);
|
||||
let persistentRnd = Object.create(null);
|
||||
let cookieStoreId = false;
|
||||
settings.onloaded(function(){
|
||||
try {
|
||||
|
@ -90,8 +90,8 @@
|
|||
settings.persistentIncognitoRndStorage:
|
||||
settings.persistentRndStorage
|
||||
);
|
||||
for (var domain in storedData){
|
||||
var value = storedData[domain];
|
||||
for (let domain in storedData){
|
||||
const value = storedData[domain];
|
||||
if (
|
||||
Array.isArray(value) &&
|
||||
value.length === 128 &&
|
||||
|
@ -103,7 +103,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
catch (error){
|
||||
// JSON is not valid -> ignore it
|
||||
}
|
||||
});
|
||||
|
@ -111,7 +111,7 @@
|
|||
|
||||
extension.message.on(function(data){
|
||||
if (data["canvasBlocker-set-domain-rnd"]){
|
||||
var {domain, incognito, rnd} = data["canvasBlocker-set-domain-rnd"];
|
||||
const {domain, incognito, rnd} = data["canvasBlocker-set-domain-rnd"];
|
||||
if (incognito === extension.inIncognitoContext){
|
||||
persistentRnd[domain] = new Uint8Array(rnd);
|
||||
}
|
||||
|
@ -130,11 +130,11 @@
|
|||
xhr.send();
|
||||
xhr = null;
|
||||
}
|
||||
catch (e){
|
||||
logging.verbose("Error in XHR:", e);
|
||||
catch (error){
|
||||
logging.verbose("Error in XHR:", error);
|
||||
}
|
||||
}
|
||||
var domain = cookieStoreId + getDomain(window);
|
||||
const domain = cookieStoreId + getDomain(window);
|
||||
if (!persistentRnd[domain]){
|
||||
// create the (sub-)domains random numbers if not existing
|
||||
persistentRnd[domain] = new Uint8Array(128);
|
||||
|
@ -165,26 +165,26 @@
|
|||
}
|
||||
};
|
||||
scope.persistent.getRng = function(length, window){
|
||||
var bitSet = new Uint32Array(getPersistentRnd(window).buffer);
|
||||
var bitSetLength = bitSet.length;
|
||||
const bitSet = new Uint32Array(getPersistentRnd(window).buffer);
|
||||
const bitSetLength = bitSet.length;
|
||||
return function(i){
|
||||
return bitSet[i % bitSetLength];
|
||||
};
|
||||
};
|
||||
scope.persistent.getBitRng = function(length, window){
|
||||
var bitSet = getPersistentRnd(window);
|
||||
const bitSet = getPersistentRnd(window);
|
||||
|
||||
return function(value, i){
|
||||
// use the last 7 bits from the value for the index of the
|
||||
// random number
|
||||
var index = value & 0x7F;
|
||||
const index = value & 0x7F;
|
||||
|
||||
// use the last 3 bits from the position and the first bit from
|
||||
// from the value to get bit to use from the random number
|
||||
var bitIndex = ((i & 0x03) << 1) | (value >>> 7);
|
||||
const bitIndex = ((i & 0x03) << 1) | (value >>> 7);
|
||||
|
||||
// extract the bit
|
||||
var bit = (bitSet[index] >>> bitIndex) & 0x01;
|
||||
const bit = (bitSet[index] >>> bitIndex) & 0x01;
|
||||
|
||||
return bit;
|
||||
};
|
||||
|
@ -196,16 +196,17 @@
|
|||
return scope.nonPersistent.getRng(length, window);
|
||||
};
|
||||
scope.constant.getPixelRng = (function(){
|
||||
var colors = Object.create(null);
|
||||
const colors = Object.create(null);
|
||||
return function getConstantPixelRng(length, window, ignoredColors){
|
||||
var rng = scope.nonPersistent.getValueRng(1024, window);
|
||||
const rng = scope.nonPersistent.getValueRng(1024, window);
|
||||
|
||||
return function(r, g, b, a, i){ // eslint-disable-line max-params
|
||||
var index = String.fromCharCode(r, g, b, a);
|
||||
// eslint-disable-next-line max-params, no-unused-vars
|
||||
return function(r, g, b, a, i){
|
||||
const index = String.fromCharCode(r, g, b, a);
|
||||
if (ignoredColors[index]){
|
||||
return [r, g, b, a];
|
||||
}
|
||||
var color = colors[index];
|
||||
let color = colors[index];
|
||||
if (!color){
|
||||
color = [
|
||||
rng(r, 0),
|
||||
|
@ -224,8 +225,8 @@
|
|||
scope.nonPersistent.name = "nonPersistent";
|
||||
scope.nonPersistent.getRng = function(length, window){
|
||||
const maxLength = 0x4000;
|
||||
var randomI = maxLength;
|
||||
var randomNumbers = new Uint32Array(Math.min(maxLength, length));
|
||||
let randomI = maxLength;
|
||||
let randomNumbers = new Uint32Array(Math.min(maxLength, length));
|
||||
return function(i){
|
||||
if (randomI >= randomNumbers.length){
|
||||
// refill the random number bucket if empty
|
||||
|
@ -235,7 +236,7 @@
|
|||
}
|
||||
window.crypto.getRandomValues(randomNumbers);
|
||||
}
|
||||
var rnd = randomNumbers[randomI];
|
||||
const rnd = randomNumbers[randomI];
|
||||
randomI += 1;
|
||||
|
||||
return rnd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue