FF60+: show additional info in popup on AMO

#312
This commit is contained in:
tophf 2018-03-23 01:44:40 +03:00
parent 18fc5fc1e5
commit 9969266379
3 changed files with 15 additions and 7 deletions

View File

@ -1087,6 +1087,10 @@
"message": "To allow access open <about:config>, right-click the list, click 'New', then 'Boolean', paste <privacy.resistFingerprinting.block_mozAddonManager> and click OK, <true>, OK, reload the <addons.mozilla.org> page.",
"description": "Note in the popup when opened on addons.mozilla.org in Firefox >= 59"
},
"unreachableAMOHintNewFF": {
"message": "In Firefox 60 and newer you'll also have to to remove AMO domain from <extensions.webextensions.restrictedDomains> in <about:config>.",
"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"

View File

@ -224,6 +224,8 @@ function $create(selector = 'div', properties, children) {
const element = ns
? document.createElementNS(ns === 'SVG' || ns === 'svg' ? 'http://www.w3.org/2000/svg' : ns, tag)
: tag === 'fragment'
? document.createDocumentFragment()
: document.createElement(tag || 'div');
for (const child of Array.isArray(children) ? children : [children]) {

View File

@ -129,12 +129,14 @@ function initPopup() {
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();
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
const renderToken = s => s[0] === '<' ? $create('b', s.slice(1, -1)) : s;
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
const noteNode = $create('fragment', note.split('\n').map(renderLine));
const target = $('p', info);
target.parentNode.insertBefore(noteNode, target);
target.remove();
}
document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild);