From 387193d347d717f1c0f3b635ea1846c28e7cea30 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 3 Dec 2017 06:02:30 +0300 Subject: [PATCH] popup: USO bug workaround for find-styles link url fixes #273 --- popup/popup.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/popup/popup.js b/popup/popup.js index f2fd4bc7..6bba06f4 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -105,11 +105,12 @@ function initPopup(url) { installed); } + const u = new URL(url); $('#find-styles-link').onclick = handleEvent.openURLandHide; $('#find-styles-link').href += - url.startsWith(location.protocol) ? - '?search_terms=Stylus' : - 'all/' + encodeURIComponent(url.startsWith('file:') ? 'file:' : url); + url.startsWith(location.protocol) ? '?search_terms=Stylus' : + u.protocol === 'file:' ? 'file:' : + u.hostname.replace(/^www\.|(\.com?)?\.\w+$/g, '').split('.').pop(); if (!url) { document.body.classList.add('blocked');