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

Added <option1|option2|...> syntax to webGL

Fixes #493
This commit is contained in:
kkapsner 2022-02-15 19:53:58 +01:00
parent fb231a070b
commit 1bd87e6953
4 changed files with 42 additions and 28 deletions

View File

@ -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){

View File

@ -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);
}
},

View File

@ -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

View File

@ -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"
}
]
}