From c7c77eb3ffe581cad7e358c6acd2d394bd6bc6ab Mon Sep 17 00:00:00 2001 From: eight Date: Sat, 24 Nov 2018 12:29:21 +0800 Subject: [PATCH] Fix: use XHR as fallback --- content/install-hook-usercss.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/install-hook-usercss.js b/content/install-hook-usercss.js index c308f2f3..f52d5a0f 100644 --- a/content/install-hook-usercss.js +++ b/content/install-hook-usercss.js @@ -58,8 +58,14 @@ // FIXME: choose a correct version // https://github.com/openstyles/stylus/issues/560 if (getChromeVersion() <= 49) { - return fetch(url).then(r => r.text()); + return fetch(url) + .then(r => r.text()) + .catch(() => fetchTextXHR(url)); } + return fetchTextXHR(url); + } + + function fetchTextXHR(url) { return new Promise((resolve, reject) => { // you can't use fetch in Chrome under 'file:' protocol const xhr = new XMLHttpRequest();