User:Jgottula/fandomdesktop.js

'use strict';

// NOTE: MediaWiki is retarded and does not support any JS syntax newer than ES5, //      nor provide any mechanism for translating ES6 to ES5 (e.g. Babel), //      probably because their shitty backend is written in PHP (lol) //      https://phabricator.wikimedia.org/T178356

dbg;

const css_names = ['background-color', 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color'];

// alpha 30% --> alpha 100% const re_30pct = /(rgba\(\s*164,\s*2,\s*57,\s*)0.3(\s*\))/gi; const str_30pct = '$1'+'1.0'+'$2';

// alpha 10% --> alpha 20% const re_10pct = /(rgba\(\s*164,\s*2,\s*57,\s*)0.1(\s*\))/gi; const str_10pct = '$1'+'0.2'+'$2';

for (var i = 0; i < document.styleSheets.length; ++i) { var sheet = document.styleSheets[i]; if (sheet.href == 'https://deadcells.gamepedia.com/load.php?lang=en&modules=site.styles&only=styles&skin=hydradark') { //console.log('sheet = document.styleSheets['+i+']'); for (var j = 0; j < sheet.cssRules.length; ++j) { var rule = sheet.cssRules[j]; if (rule.type != CSSRule.STYLE_RULE) continue; for (var k = 0; k < css_names.length; ++k) { var name = css_names[k]; if (rule.styleMap.has(name)) { //console.log(' rule has "'+name+'": "'+rule.styleMap.get(name)+'"'); if (re_10pct.test(rule.styleMap.get(name))) { //console.log(' old: "'+rule.styleMap.get(name)+'"'); rule.styleMap.set(name, rule.styleMap.get(name).toString.replaceAll(re_10pct, str_10pct)); //console.log(' new: "'+rule.styleMap.get(name)+'"'); }                   if (re_30pct.test(rule.styleMap.get(name))) { //console.log(' old: "'+rule.styleMap.get(name)+'"'); rule.styleMap.set(name, rule.styleMap.get(name).toString.replaceAll(re_30pct, str_30pct)); //console.log(' new: "'+rule.styleMap.get(name)+'"'); }               }            }        }    } }

function dbg {	// continually re-check the fragment and query params in case those // happen to change later on and we're debugging persistent/latent code var url = new URL(window.location.href); if (url.hash.includes('jgdebug') || url.searchParams.has('jgdebug')) { debugger; } }