fix installing Usw styles
Remove comment
This commit is contained in:
parent
63db0d7650
commit
f856dfb010
|
@ -102,7 +102,7 @@ const URLS = {
|
||||||
const id = URLS.extractUSwId(url);
|
const id = URLS.extractUSwId(url);
|
||||||
return id ? `${URLS.usw}style/${id}` : '';
|
return id ? `${URLS.usw}style/${id}` : '';
|
||||||
},
|
},
|
||||||
makeUSwArchiveCodeUrl: id => `${URLS.usw}api/style/${id}.user.css`,
|
makeUswCodeUrl: id => `${URLS.usw}api/style/${id}.user.css`,
|
||||||
|
|
||||||
supported: url => (
|
supported: url => (
|
||||||
url.startsWith('http') ||
|
url.startsWith('http') ||
|
||||||
|
|
|
@ -291,7 +291,7 @@
|
||||||
|
|
||||||
// Note to Tophf, we send a direct image link over shotName, as we are currently not
|
// Note to Tophf, we send a direct image link over shotName, as we are currently not
|
||||||
// hosting any images. Which soon will be different.
|
// hosting any images. Which soon will be different.
|
||||||
const isDirectImageLink = /(.jpg|.webp|.avif|.jpeg|.png)$/g.match(shotName);
|
const isDirectImageLink = /(.jpg|.webp|.avif|.jpeg|.png)$/g.test(shotName);
|
||||||
const auto = URLS.uso + `auto_style_screenshots/${id}${USO_AUTO_PIC_SUFFIX}`;
|
const auto = URLS.uso + `auto_style_screenshots/${id}${USO_AUTO_PIC_SUFFIX}`;
|
||||||
Object.assign($('.search-result-screenshot', entry), {
|
Object.assign($('.search-result-screenshot', entry), {
|
||||||
src: isDirectImageLink ? shotName
|
src: isDirectImageLink ? shotName
|
||||||
|
@ -407,7 +407,7 @@
|
||||||
async function install() {
|
async function install() {
|
||||||
const entry = this.closest('.search-result');
|
const entry = this.closest('.search-result');
|
||||||
const result = /** @type IndexEntry */ entry._result;
|
const result = /** @type IndexEntry */ entry._result;
|
||||||
const {i: id} = result;
|
const {i: id, isUsw} = result;
|
||||||
const installButton = $('.search-result-install', entry);
|
const installButton = $('.search-result-install', entry);
|
||||||
|
|
||||||
showSpinner(entry);
|
showSpinner(entry);
|
||||||
|
@ -418,10 +418,7 @@
|
||||||
result.pingbackTimer = setTimeout(download, PINGBACK_DELAY,
|
result.pingbackTimer = setTimeout(download, PINGBACK_DELAY,
|
||||||
`${URLS.uso}styles/install/${id}?source=stylish-ch`);
|
`${URLS.uso}styles/install/${id}?source=stylish-ch`);
|
||||||
|
|
||||||
// Any recommendation how to detect USw here?
|
const updateUrl = isUsw ? URLS.makeUswCodeUrl(id) : URLS.makeUsoArchiveCodeUrl(id);
|
||||||
// the `uw` was purely for this situation to make sure if we need
|
|
||||||
// create a USw url or an Uso-Archive url.
|
|
||||||
const updateUrl = URLS.makeUsoArchiveCodeUrl(id);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sourceCode = await download(updateUrl);
|
const sourceCode = await download(updateUrl);
|
||||||
|
@ -488,6 +485,9 @@
|
||||||
index = index.concat(res.filter(res => res.f === 'uso'));
|
index = index.concat(res.filter(res => res.f === 'uso'));
|
||||||
}).catch(() => {}),
|
}).catch(() => {}),
|
||||||
download(USW_INDEX_URL, {responseType: 'json'}).then(res => {
|
download(USW_INDEX_URL, {responseType: 'json'}).then(res => {
|
||||||
|
res.data.map(style => {
|
||||||
|
style.isUsw = true;
|
||||||
|
});
|
||||||
index = index.concat(res.data);
|
index = index.concat(res.data);
|
||||||
}).catch(() => {}),
|
}).catch(() => {}),
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user