diff --git a/content/install-hook-usercss.js b/content/install-hook-usercss.js index 622b3143..c88c13ea 100644 --- a/content/install-hook-usercss.js +++ b/content/install-hook-usercss.js @@ -54,6 +54,12 @@ } function fetchText(url) { + // XHR throws in Chrome 49 + // FIXME: choose a correct version + // https://github.com/openstyles/stylus/issues/560 + if (getChromeVersion() <= 49) { + return fetch(url).then(r => r.text()); + } return new Promise((resolve, reject) => { // you can't use fetch in Chrome under 'file:' protocol const xhr = new XMLHttpRequest(); @@ -64,6 +70,11 @@ }); } + function getChromeVersion() { + const match = navigator.userAgent.match(/chrome\/(\d+)/i); + return match && Number(match[1]); + } + function start() { timer = timer || setTimeout(check, DELAY); }