diff --git a/popup/popup.js b/popup/popup.js index 6bba06f4..6b90bfb9 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -105,19 +105,20 @@ 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' : - u.protocol === 'file:' ? 'file:' : - u.hostname.replace(/^www\.|(\.com?)?\.\w+$/g, '').split('.').pop(); - if (!url) { document.body.classList.add('blocked'); document.body.insertBefore(template.unavailableInfo, document.body.firstChild); return; } + const u = tryCatch(() => new URL(url)); + $('#find-styles-link').onclick = handleEvent.openURLandHide; + $('#find-styles-link').href += + !u ? '' : + u.protocol === 'file:' ? 'file:' : + u.protocol === location.protocol ? '?search_terms=Stylus' : + u.hostname.replace(/^www\.|(\.com?)?\.\w+$/g, '').split('.').pop(); + getActiveTab().then(function ping(tab, retryCountdown = 10) { sendMessage({tabId: tab.id, method: 'ping', frameId: 0}, pong => { if (pong) {