use installation url on known sites as homepage

This commit is contained in:
tophf 2020-10-07 17:59:21 +03:00
parent 78b0e33ba4
commit 4913da2e19
2 changed files with 9 additions and 2 deletions

View File

@ -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 => {

View File

@ -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();
});