MediaWiki:Gadget-dark-vector.js

mw.loader.using("jquery", function { //Sometimes JQuery just doesn't load fast enough iirc, so let's just wait for it    $("td[style]").each(function  { //Go over each td with the style attribute var _c = this.style.backgroundColor.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*(\d+)\s*)?\)$/i); //Match the backgroundColor: https://stackoverflow.com/a/11068286/10211613 if (_c == null) return; //If no background color found, skip _c = _c.slice(1, 5).map(function (e, i) { return parseInt(i == 3 ? parseInt(e) : (parseInt(e) - 175)) }); //Get array elements 1-4, then parse them as an int, and subtract 175 from them, except if it's the alpha (index: 3) if (isNaN(_c[3])) _c[3] = 1; //If no alpha was defined (example: rgb), set it to 1 this.style.backgroundColor = "rgba(" + _c.join(",") + ")"; //Set the new background color }) })