Add: enable usercss updateURL (#661)
* Add: use metadata.updateURL as style.updateUrl * Change: only use the installation URL as the update URL if not specified in usercss * Fix: hide live reload checkbox according to installationUrl
This commit is contained in:
parent
dfb9db34c3
commit
4262882ac9
|
@ -307,9 +307,9 @@
|
||||||
|
|
||||||
// set updateUrl
|
// set updateUrl
|
||||||
const checker = $('.set-update-url input[type=checkbox]');
|
const checker = $('.set-update-url input[type=checkbox]');
|
||||||
// prefer the installation URL unless drag'n'dropped on the manage page
|
// only use the installation URL if not specified in usercss
|
||||||
const installationUrl = (params.get('updateUrl') || '').replace(/^blob.+/, '');
|
const installationUrl = (params.get('updateUrl') || '').replace(/^blob.+/, '');
|
||||||
const updateUrl = new URL(installationUrl || style.updateUrl || DUMMY_URL);
|
const updateUrl = new URL(style.updateUrl || installationUrl || DUMMY_URL);
|
||||||
if (dup && dup.updateUrl === updateUrl.href) {
|
if (dup && dup.updateUrl === updateUrl.href) {
|
||||||
checker.checked = true;
|
checker.checked = true;
|
||||||
// there is no way to "unset" updateUrl, you can only overwrite it.
|
// there is no way to "unset" updateUrl, you can only overwrite it.
|
||||||
|
@ -335,7 +335,7 @@
|
||||||
|
|
||||||
// live reload
|
// live reload
|
||||||
const setLiveReload = $('.live-reload input[type=checkbox]');
|
const setLiveReload = $('.live-reload input[type=checkbox]');
|
||||||
if (updateUrl.protocol !== 'file:') {
|
if (!installationUrl || !installationUrl.startsWith('file:')) {
|
||||||
setLiveReload.parentNode.remove();
|
setLiveReload.parentNode.remove();
|
||||||
} else {
|
} else {
|
||||||
setLiveReload.addEventListener('change', () => {
|
setLiveReload.addEventListener('change', () => {
|
||||||
|
|
|
@ -7,7 +7,7 @@ const usercss = (() => {
|
||||||
author: undefined,
|
author: undefined,
|
||||||
description: undefined,
|
description: undefined,
|
||||||
homepageURL: 'url',
|
homepageURL: 'url',
|
||||||
// updateURL: 'updateUrl',
|
updateURL: 'updateUrl',
|
||||||
name: undefined,
|
name: undefined,
|
||||||
};
|
};
|
||||||
const RX_META = /\/\*!?\s*==userstyle==[\s\S]*?==\/userstyle==\s*\*\//i;
|
const RX_META = /\/\*!?\s*==userstyle==[\s\S]*?==\/userstyle==\s*\*\//i;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user