diff --git a/background/style-manager.js b/background/style-manager.js index 4ddb6411..4ae2a5c2 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -1,6 +1,6 @@ /* eslint no-eq-null: 0, eqeqeq: [2, "smart"] */ /* global createCache db calcStyleDigest db tryRegExp styleCodeEmpty styleSectionGlobal - getStyleWithNoCode msg sync uuidv4 */ + getStyleWithNoCode msg sync uuidv4 URLS */ /* exported styleManager */ 'use strict'; @@ -226,6 +226,13 @@ const styleManager = (() => { if (!reason) { reason = style ? 'update' : 'install'; } + let url = !data.url && data.updateUrl; + if (url) { + const usoId = URLS.extractUsoArchiveId(url); + url = usoId && `${URLS.usoArchive}?style=${usoId}` || + URLS.extractGreasyForkId(url) && url.match(/^.*?\/\d+/)[0]; + if (url) data.url = data.installationUrl = url; + } // FIXME: update updateDate? what about usercss config? return calcStyleDigest(data) .then(digest => { diff --git a/edit/source-editor.js b/edit/source-editor.js index a9f8bf22..b3292606 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -46,7 +46,7 @@ function createSourceEditor({style, onTitleChanged}) { metaCompiler.onUpdated(meta => { style.usercssData = meta; style.name = meta.name; - style.url = meta.homepageURL; + style.url = meta.homepageURL || style.installationUrl; updateMeta(); });