diff --git a/background/update.js b/background/update.js index 7f5b60ce..59268a14 100644 --- a/background/update.js +++ b/background/update.js @@ -156,7 +156,8 @@ } // USO can't handle POST requests for style json return download(style.updateUrl, {body: null}) - .then(text => tryJSONparse(text)); + // USO may not provide a correctly updated originalMd5 (#555) + .then(text => Object.assign(tryJSONparse(text), {originalMd5: md5})); }); } diff --git a/popup/search-results.js b/popup/search-results.js index 611a18e9..b89cd377 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -510,7 +510,6 @@ window.addEventListener('showStyles:done', function _() { const installButton = $('.search-result-install', entry); installButton.onclick = onInstallClicked; - if ((result.style_settings || []).length > 0) { // Style has customizations installButton.classList.add('customize'); @@ -552,11 +551,13 @@ window.addEventListener('showStyles:done', function _() { Promise.all([ fetchStyleJson(result), fetchStyleSettings(result), + fetchMd5(result) ]) - .then(([style, settings]) => { + .then(([style, settings, md5]) => { pingback(result); // show a 'config-on-homepage' icon in the popup style.updateUrl += settings.length ? '?' : ''; + style.originalMd5 = md5; return API.installStyle(style); }) .catch(reason => { @@ -578,6 +579,19 @@ window.addEventListener('showStyles:done', function _() { return result.style_settings; }); } + + function fetchMd5(result) { + return API.download({ + url: UPDATE_URL.replace('%', result.id), + timeout: 60e3, + // USO can't handle POST requests for style json + body: null, + }) + .catch(error => { + alert('Error' + (error ? '\n' + error : '')); + throw error; + }); + } } function pingback(result) {