From 6246fdee7c645341380daa8e6dd505247c0ee264 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 26 Oct 2016 23:11:34 +0100 Subject: [PATCH] Fix room tinting Looks like the cachebuster stuff in https://github.com/vector-im/vector-web/pull/2515 broke room tinting. Add a fix, along with some ranting. --- src/Tinter.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Tinter.js b/src/Tinter.js index 6d0365cac2..336fb90fa2 100644 --- a/src/Tinter.js +++ b/src/Tinter.js @@ -35,7 +35,7 @@ var keyRgb = [ // x * 118 + 255 - 255 * x = 234 // x * 118 - x * 255 = 234 - 255 // (255 - 118) x = 255 - 234 -// x = (255 - 234) / (255 - 118) = 0.16 +// x = (255 - 234) / (255 - 118) = 0.16 // The colour keys to be replaced as referred to in SVGs var keyHex = [ @@ -90,7 +90,20 @@ function calcCssFixups() { // See also #vector:matrix.org/$145357669685386ebCfr:matrix.org // ...except some browsers apparently return stylesheets without // hrefs, which we have no choice but ignore right now - if (ss.href && !ss.href.endsWith("/bundle.css")) continue; + + // XXX seriously? we are hardcoding the name of vector's CSS file in + // here? + // + // Why do we need to limit it to vector's CSS file anyway - if there + // are other CSS files affecting the doc don't we want to apply the + // same transformations to them? + // + // Iterating through the CSS looking for matches to hack on feels + // pretty horrible anyway. And what if the application skin doesn't use + // Vector Green as its primary color? + + if (ss.href && !ss.href.match(/\/bundle.*\.css$/)) continue; + if (!ss.cssRules) continue; for (var j = 0; j < ss.cssRules.length; j++) { var rule = ss.cssRules[j];