From 12eb24361063d62fa19811bef471bdb7428f4ac1 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 16 Jan 2022 20:22:42 +0300 Subject: [PATCH] replace installer if another file is drag'n'dropped --- background/usercss-install-helper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/background/usercss-install-helper.js b/background/usercss-install-helper.js index 0773ffb5..c11f08fd 100644 --- a/background/usercss-install-helper.js +++ b/background/usercss-install-helper.js @@ -74,6 +74,10 @@ bgReady.all.then(() => { ) && download(url); } + function makeInstallerUrl(url) { + return `${URLS.installUsercss}?updateUrl=${encodeURIComponent(url)}`; + } + function makeUsercssGlobs(host, path) { return '%css,%css?*,%styl,%styl?*'.replace(/%/g, `*://${host}${path}.user.`).split(','); } @@ -82,7 +86,7 @@ bgReady.all.then(() => { if (url.includes('.user.') && /^(https?|file|ftps?):/.test(url) && /\.user\.(css|styl)$/.test(url.split(/[#?]/, 1)[0]) && - !oldUrl.startsWith(URLS.installUsercss)) { + !oldUrl.startsWith(makeInstallerUrl(url))) { const inTab = url.startsWith('file:') && !chrome.app; const code = await (inTab ? loadFromFile : loadFromUrl)(tabId, url); if (!/^\s* { } async function openInstallerPage(tabId, url, {code, inTab} = {}) { - const newUrl = `${URLS.installUsercss}?updateUrl=${encodeURIComponent(url)}`; + const newUrl = makeInstallerUrl(url); if (inTab) { const tab = await browser.tabs.get(tabId); return openURL({