diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ab45b821..85938e69 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -528,6 +528,9 @@ "message": "Check for updates", "description": "Label for the checkbox to save current URL for update check" }, + "installUpdateUnavailable": { + "message": "To enable check for updates, drop the file on the tab strip or specify @updateURL in the style metadata." + }, "license": { "message": "License", "description": "Label for the license" @@ -611,6 +614,9 @@ "message": "An error occurred while watching the file", "description": "The label of live-reload error" }, + "liveReloadUnavailable": { + "message": "To enable live reload, drop the file on the tab strip (the area where the tab titles are shown)." + }, "manageFilters": { "message": "Filters", "description": "Label for filters container" diff --git a/install-usercss/install-usercss.css b/install-usercss/install-usercss.css index cdec1162..7b22d04c 100644 --- a/install-usercss/install-usercss.css +++ b/install-usercss/install-usercss.css @@ -306,7 +306,7 @@ li { user-select: auto; } -label { +label:not(.unavailable) { padding-left: 16px; position: relative; } diff --git a/install-usercss/install-usercss.js b/install-usercss/install-usercss.js index 5b04d870..663b40ec 100644 --- a/install-usercss/install-usercss.js +++ b/install-usercss/install-usercss.js @@ -3,6 +3,8 @@ 'use strict'; (() => { + const DUMMY_URL = 'foo:'; + // TODO: remove .replace(/^\?/, '') when minimum_chrome_version >= 52 (https://crbug.com/601425) const params = new URLSearchParams(location.search.replace(/^\?/, '')); let liveReload = false; @@ -14,7 +16,8 @@ let port; if (params.has('direct')) { - $('.live-reload').remove(); + $('.live-reload').textContent = t('liveReloadUnavailable'); + $('.live-reload').classList.add('unavailable'); getCodeDirectly(); } else { port = chrome.tabs.connect(tabId); @@ -308,15 +311,17 @@ const checker = $('.set-update-url input[type=checkbox]'); // prefer the installation URL unless drag'n'dropped on the manage page const installationUrl = (params.get('updateUrl') || '').replace(/^blob.+/, ''); - const updateUrl = new URL(installationUrl || style.updateUrl || 'foo:bar'); + const updateUrl = new URL(installationUrl || style.updateUrl || DUMMY_URL); $('.set-update-url > span').textContent = t('installUpdateFromLabel'); if (dup && dup.updateUrl === updateUrl.href) { checker.checked = true; // there is no way to "unset" updateUrl, you can only overwrite it. checker.disabled = true; - } else if (updateUrl.protocol === 'foo:') { + } else if (updateUrl.href === DUMMY_URL) { // drag'n'dropped on the manage page and the style doesn't have @updateURL - checker.disabled = true; + $('.set-update-url').textContent = t('installUpdateUnavailable'); + $('.set-update-url').classList.add('unavailable'); + return; } else if (updateUrl.protocol !== 'file:') { checker.checked = true; style.updateUrl = updateUrl.href;