From 4913da2e1956bac44dee9f93b32e23671b881657 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 7 Oct 2020 17:59:21 +0300 Subject: [PATCH] use installation url on known sites as homepage --- background/style-manager.js | 9 ++++++++- edit/source-editor.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) 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(); });