diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 1f0e84cf..57d078bf 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1031,6 +1031,18 @@ "message": "Stylus can access file:// URLs only if you enable the corresponding checkbox for Stylus extension on chrome://extensions page.", "description": "Note in the toolbar popup for file:// URLs" }, + "unreachableAMO": { + "message": "Firefox forbids access to the site.", + "description": "Note in the popup displayed when opened on addons.mozilla.org" + }, + "unreachableAMOHint": { + "message": "To allow access open , right-click the list, click 'New', then 'Boolean', paste and click OK, , OK, reload the page.", + "description": "Note in the popup when opened on addons.mozilla.org in Firefox >= 59" + }, + "unreachableAMOHintOldFF": { + "message": "Only Firefox 59 and newer can be configured to allow WebExtensions to add style elements on CSP-protected sites such as this one.", + "description": "Note in the popup when opened on addons.mozilla.org in Firefox < 59" + }, "updateCheckFailBadResponseCode": { "message": "Update failed: server responded with code $code$.", "description": "Text that displays when an update check failed because the response code indicates an error", diff --git a/js/messaging.js b/js/messaging.js index c4abfe81..fab5d692 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -45,7 +45,7 @@ const URLS = { chromeProtectsNTP: CHROME >= 3161, supported: url => ( - url.startsWith('http') && !url.startsWith(URLS.browserWebStore) || + url.startsWith('http') && (FIREFOX || !url.startsWith(URLS.browserWebStore)) || url.startsWith('ftp') || url.startsWith('file') || url.startsWith(URLS.ownOrigin) || diff --git a/popup/popup.js b/popup/popup.js index d328cf1e..f9e6fb8d 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -122,17 +122,24 @@ function initPopup(url) { ignoreChromeError(); // FF and some Chrome forks (e.g. CentBrowser) implement tab-on-demand // so we'll wait a bit to handle popup being invoked right after switching - if ( - retryCountdown > 0 && ( + if (retryCountdown > 0 && ( tab.status !== 'complete' || - FIREFOX && tab.url === 'about:blank' - ) - ) { + FIREFOX && tab.url === 'about:blank')) { setTimeout(ping, 100, tab, --retryCountdown); - } else { - document.body.classList.add('unreachable'); - document.body.insertBefore(template.unreachableInfo, document.body.firstChild); + return; } + const info = template.unreachableInfo; + if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) { + $('label', info).textContent = t('unreachableAMO'); + $('p', info).insertAdjacentElement('afterend', + $create('p', + t(FIREFOX < 59 ? 'unreachableAMOHintOldFF' : 'unreachableAMOHint') + .split(/(<.*?>)/) + .map(s => s[0] === '<' ? $create('b', s.slice(1, -1)) : s))); + $('p', info).remove(); + } + document.body.classList.add('unreachable'); + document.body.insertBefore(info, document.body.firstChild); }); });