diff --git a/background/style-manager.js b/background/style-manager.js index 6542ebbd..d0d8cd17 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -253,6 +253,7 @@ const styleManager = (() => { if (style.id == null) { delete style.id; } + fixUsoMd5Issue(style); return db.exec('put', style) .then(event => { if (style.id == null) { @@ -380,6 +381,7 @@ const styleManager = (() => { return; } for (const style of styleList) { + fixUsoMd5Issue(style); styles.set(style.id, { appliesTo: new Set(), data: style @@ -479,4 +481,12 @@ const styleManager = (() => { function getUrlNoHash(url) { return url.split('#')[0]; } + + // The md5Url provided by USO includes a duplicate "update" subdomain (see #523), + // This fixes any already installed styles containing this error + function fixUsoMd5Issue(style) { + if (style && style.md5Url && style.md5Url.includes('update.update.userstyles')) { + style.md5Url = style.md5Url.replace('update.update.userstyles', 'update.userstyles'); + } + } })(); diff --git a/background/style-via-api.js b/background/style-via-api.js index e5fdf6ac..79f5c289 100644 --- a/background/style-via-api.js +++ b/background/style-via-api.js @@ -159,7 +159,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => { return; } const tabFrames = cache.get(tabId); - if (frameId in tabFrames) { + if (tabFrames && frameId in tabFrames) { delete tabFrames[frameId]; if (isEmpty(tabFrames)) { onTabRemoved(tabId); diff --git a/content/install-hook-userstyles.js b/content/install-hook-userstyles.js index 72ea6862..797d84ee 100644 --- a/content/install-hook-userstyles.js +++ b/content/install-hook-userstyles.js @@ -218,6 +218,14 @@ }); } + // USO providing md5Url as "https://update.update.userstyles.org/#####.md5" + // instead of "https://update.userstyles.org/#####.md5" + function tryFixMd5(style) { + if (style && style.md5Url && style.md5Url.includes('update.update')) { + style.md5Url = style.md5Url.replace('update.update', 'update'); + } + return style; + } function getStyleJson() { return getResource(getStyleURL(), {responseType: 'json'}) @@ -236,6 +244,7 @@ return style; }); }) + .then(tryFixMd5) .catch(() => null); }