From 90aadfd7283ed86ac359fbd4b300d548db8b298e Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 14 Oct 2018 02:43:52 +0800 Subject: [PATCH] Fix: drop __ERROR__ --- content/install-hook-userstyles.js | 32 ++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/content/install-hook-userstyles.js b/content/install-hook-userstyles.js index 7e79652d..72ea6862 100644 --- a/content/install-hook-userstyles.js +++ b/content/install-hook-userstyles.js @@ -203,25 +203,19 @@ function getResource(url, options) { - return new Promise(resolve => { - if (url.startsWith('#')) { - resolve(document.getElementById(url.slice(1)).textContent); - } else { - API.download(Object.assign({ - url, - timeout: 60e3, - // USO can't handle POST requests for style json - body: null, - }, options)).then(result => { - const error = result && result.__ERROR__; - if (error) { - alert('Error' + (error ? '\n' + error : '')); - } else { - resolve(result); - } - }); - } - }); + if (url.startsWith('#')) { + return Promise.resolve(document.getElementById(url.slice(1)).textContent); + } + return API.download(Object.assign({ + url, + timeout: 60e3, + // USO can't handle POST requests for style json + body: null, + }, options)) + .catch(error => { + alert('Error' + (error ? '\n' + error : '')); + throw error; + }); }