restore CWS check in popup
This commit is contained in:
parent
57e462ee31
commit
e7ca14a6d5
|
@ -504,7 +504,7 @@ body > .actions {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.blocked #installed > *,
|
body.blocked #installed > :not(.frame),
|
||||||
body.blocked .actions > .main-controls {
|
body.blocked .actions > .main-controls {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ async function initTabUrls() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {chrome.webNavigation.GetAllFrameResultDetails[]} frames */
|
/** @param {chrome.webNavigation.GetAllFrameResultDetails[]} frames */
|
||||||
function initPopup(frames) {
|
async function initPopup(frames) {
|
||||||
installed = $('#installed');
|
installed = $('#installed');
|
||||||
|
|
||||||
setPopupWidth();
|
setPopupWidth();
|
||||||
|
@ -170,52 +170,52 @@ function initPopup(frames) {
|
||||||
el.onclick = () => el.classList.toggle('expanded');
|
el.onclick = () => el.classList.toggle('expanded');
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveTab().then(function ping(tab, retryCountdown = 10) {
|
const isStore = tabURL.startsWith(URLS.browserWebStore);
|
||||||
msg.sendTab(tab.id, {method: 'ping'}, {frameId: 0})
|
if (isStore && !FIREFOX) {
|
||||||
.catch(() => false)
|
blockPopup();
|
||||||
.then(pong => {
|
return;
|
||||||
if (pong) {
|
}
|
||||||
return;
|
|
||||||
}
|
for (let retryCountdown = 10; retryCountdown-- > 0;) {
|
||||||
// FF and some Chrome forks (e.g. CentBrowser) implement tab-on-demand
|
const tab = await getActiveTab();
|
||||||
// so we'll wait a bit to handle popup being invoked right after switching
|
if (await msg.sendTab(tab.id, {method: 'ping'}, {frameId: 0}).catch(() => {})) {
|
||||||
if (retryCountdown > 0 && (
|
return;
|
||||||
tab.status !== 'complete' ||
|
}
|
||||||
FIREFOX && tab.url === ABOUT_BLANK)) {
|
if (tab.status === 'complete' && (!FIREFOX || tab.url !== ABOUT_BLANK)) {
|
||||||
setTimeout(ping, 100, tab, --retryCountdown);
|
break;
|
||||||
return;
|
}
|
||||||
}
|
// FF and some Chrome forks (e.g. CentBrowser) implement tab-on-demand
|
||||||
const info = t.template.unreachableInfo;
|
// so we'll wait a bit to handle popup being invoked right after switching
|
||||||
if (!FIREFOX) {
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
// Chrome "Allow access to file URLs" in chrome://extensions message
|
}
|
||||||
info.appendChild($create('p', t('unreachableFileHint')));
|
const info = t.template.unreachableInfo;
|
||||||
}
|
if (!FIREFOX) {
|
||||||
if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) {
|
// Chrome "Allow access to file URLs" in chrome://extensions message
|
||||||
$('label', info).textContent = t('unreachableAMO');
|
info.appendChild($create('p', t('unreachableFileHint')));
|
||||||
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
|
} else if (isStore) {
|
||||||
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
|
$('label', info).textContent = t('unreachableAMO');
|
||||||
const renderToken = s => s[0] === '<'
|
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
|
||||||
? $create('a', {
|
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
|
||||||
textContent: s.slice(1, -1),
|
const renderToken = s => s[0] === '<'
|
||||||
onclick: handleEvent.copyContent,
|
? $create('a', {
|
||||||
href: '#',
|
textContent: s.slice(1, -1),
|
||||||
className: 'copy',
|
onclick: handleEvent.copyContent,
|
||||||
tabIndex: 0,
|
href: '#',
|
||||||
title: t('copy'),
|
className: 'copy',
|
||||||
})
|
tabIndex: 0,
|
||||||
: s;
|
title: t('copy'),
|
||||||
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
|
})
|
||||||
const noteNode = $create('fragment', note.split('\n').map(renderLine));
|
: s;
|
||||||
info.appendChild(noteNode);
|
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
|
||||||
}
|
const noteNode = $create('fragment', note.split('\n').map(renderLine));
|
||||||
// Inaccessible locally hosted file type, e.g. JSON, PDF, etc.
|
info.appendChild(noteNode);
|
||||||
if (tabURL.length - tabURL.lastIndexOf('.') <= 5) {
|
}
|
||||||
info.appendChild($create('p', t('InaccessibleFileHint')));
|
// Inaccessible locally hosted file type, e.g. JSON, PDF, etc.
|
||||||
}
|
if (tabURL.length - tabURL.lastIndexOf('.') <= 5) {
|
||||||
document.body.classList.add('unreachable');
|
info.appendChild($create('p', t('InaccessibleFileHint')));
|
||||||
document.body.insertBefore(info, document.body.firstChild);
|
}
|
||||||
});
|
document.body.classList.add('unreachable');
|
||||||
});
|
document.body.insertBefore(info, document.body.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */
|
/** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user