mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 04:40:20 +01:00
parent
fb231a070b
commit
1bd87e6953
@ -145,6 +145,9 @@
|
||||
case "{random renderer}":
|
||||
return webglRandom.getRandomRenderer(window);
|
||||
}
|
||||
if (settingValue.startsWith("<") && settingValue.endsWith(">")){
|
||||
return webglRandom.pickOneFromTree(settingValue, window);
|
||||
}
|
||||
return settingValue;
|
||||
},
|
||||
decimal: function(originalValue, definition, window){
|
||||
|
@ -51,6 +51,35 @@
|
||||
const vendor = scope.vendors[getRandomVendorIndex(window)];
|
||||
return vendor.renderers[getRandomRendererIndex(window)];
|
||||
};
|
||||
scope.pickOneFromTree = function pickOneFromTree(treeString, window){
|
||||
function pickOne(string){
|
||||
const options = [];
|
||||
let cumulate = "";
|
||||
let index = 0;
|
||||
for (const l = string.length; index < l; index += 1){
|
||||
const char = string.charAt(index);
|
||||
if (char === "|"){
|
||||
options.push(cumulate);
|
||||
cumulate = "";
|
||||
}
|
||||
else if (char === "<"){
|
||||
const subPick = pickOne(string.substring(index + 1));
|
||||
cumulate += subPick.value;
|
||||
index += 1 + subPick.endIndex;
|
||||
}
|
||||
else if (char === ">"){
|
||||
break;
|
||||
}
|
||||
else {
|
||||
cumulate += char;
|
||||
}
|
||||
}
|
||||
options.push(cumulate);
|
||||
const optionRng = randomSupply.getIndexRng(1, options.length, window);
|
||||
return {value: options[optionRng(0)], endIndex: index};
|
||||
}
|
||||
return pickOne(treeString).value;
|
||||
};
|
||||
|
||||
scope.vendors = [
|
||||
{
|
||||
@ -93,34 +122,7 @@
|
||||
return words[parseInt(index, 36)];
|
||||
}
|
||||
);
|
||||
|
||||
function pickOne(string){
|
||||
const options = [];
|
||||
let cumulate = "";
|
||||
let index = 0;
|
||||
for (const l = string.length; index < l; index += 1){
|
||||
const char = string.charAt(index);
|
||||
if (char === "|"){
|
||||
options.push(cumulate);
|
||||
cumulate = "";
|
||||
}
|
||||
else if (char === "<"){
|
||||
const subPick = pickOne(string.substring(index + 1));
|
||||
cumulate += subPick.value;
|
||||
index += 1 + subPick.endIndex;
|
||||
}
|
||||
else if (char === ">"){
|
||||
break;
|
||||
}
|
||||
else {
|
||||
cumulate += char;
|
||||
}
|
||||
}
|
||||
options.push(cumulate);
|
||||
const optionRng = randomSupply.getIndexRng(1, options.length, window);
|
||||
return {value: options[optionRng(0)], endIndex: index};
|
||||
}
|
||||
return pickOne(compressed).value;
|
||||
return scope.pickOneFromTree(compressed, window);
|
||||
|
||||
}
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ Version 1.8:
|
||||
- added SVG protection
|
||||
- added notice when dom.webAudio.enabled is set to false
|
||||
- added {random vendor} and {random renderer} to UNMASKED_VENDOR_WEBGL and UNMASKED_RENDERER_WEBGL to use a random value from a given list
|
||||
- added <option1|option2|...> syntax to UNMASKED_VENDOR_WEBGL and UNMASKED_RENDERER_WEBGL
|
||||
|
||||
fixes:
|
||||
- errors in URL regular expressions broke CB
|
||||
|
@ -213,6 +213,14 @@
|
||||
{
|
||||
"version": "1.8Alpha20220130",
|
||||
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.8Alpha20220130-an+fx.xpi"
|
||||
},
|
||||
{
|
||||
"version": "1.8Alpha20220214",
|
||||
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.8Alpha20220214-an+fx.xpi"
|
||||
},
|
||||
{
|
||||
"version": "1.8Alpha20220215",
|
||||
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.8Alpha20220215-an+fx.xpi"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user