restore CWS check in popup

This commit is contained in:
tophf 2020-11-21 17:50:58 +03:00
parent 57e462ee31
commit e7ca14a6d5
2 changed files with 48 additions and 48 deletions

View File

@ -504,7 +504,7 @@ body > .actions {
vertical-align: middle;
}
body.blocked #installed > *,
body.blocked #installed > :not(.frame),
body.blocked .actions > .main-controls {
display: none;
}

View File

@ -129,7 +129,7 @@ async function initTabUrls() {
}
/** @param {chrome.webNavigation.GetAllFrameResultDetails[]} frames */
function initPopup(frames) {
async function initPopup(frames) {
installed = $('#installed');
setPopupWidth();
@ -170,52 +170,52 @@ function initPopup(frames) {
el.onclick = () => el.classList.toggle('expanded');
}
getActiveTab().then(function ping(tab, retryCountdown = 10) {
msg.sendTab(tab.id, {method: 'ping'}, {frameId: 0})
.catch(() => false)
.then(pong => {
if (pong) {
return;
}
// 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 && (
tab.status !== 'complete' ||
FIREFOX && tab.url === ABOUT_BLANK)) {
setTimeout(ping, 100, tab, --retryCountdown);
return;
}
const info = t.template.unreachableInfo;
if (!FIREFOX) {
// Chrome "Allow access to file URLs" in chrome://extensions message
info.appendChild($create('p', t('unreachableFileHint')));
}
if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) {
$('label', info).textContent = t('unreachableAMO');
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
const renderToken = s => s[0] === '<'
? $create('a', {
textContent: s.slice(1, -1),
onclick: handleEvent.copyContent,
href: '#',
className: 'copy',
tabIndex: 0,
title: t('copy'),
})
: s;
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
const noteNode = $create('fragment', note.split('\n').map(renderLine));
info.appendChild(noteNode);
}
// Inaccessible locally hosted file type, e.g. JSON, PDF, etc.
if (tabURL.length - tabURL.lastIndexOf('.') <= 5) {
info.appendChild($create('p', t('InaccessibleFileHint')));
}
document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild);
});
});
const isStore = tabURL.startsWith(URLS.browserWebStore);
if (isStore && !FIREFOX) {
blockPopup();
return;
}
for (let retryCountdown = 10; retryCountdown-- > 0;) {
const tab = await getActiveTab();
if (await msg.sendTab(tab.id, {method: 'ping'}, {frameId: 0}).catch(() => {})) {
return;
}
if (tab.status === 'complete' && (!FIREFOX || tab.url !== ABOUT_BLANK)) {
break;
}
// 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
await new Promise(resolve => setTimeout(resolve, 100));
}
const info = t.template.unreachableInfo;
if (!FIREFOX) {
// Chrome "Allow access to file URLs" in chrome://extensions message
info.appendChild($create('p', t('unreachableFileHint')));
} else if (isStore) {
$('label', info).textContent = t('unreachableAMO');
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
const renderToken = s => s[0] === '<'
? $create('a', {
textContent: s.slice(1, -1),
onclick: handleEvent.copyContent,
href: '#',
className: 'copy',
tabIndex: 0,
title: t('copy'),
})
: s;
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
const noteNode = $create('fragment', note.split('\n').map(renderLine));
info.appendChild(noteNode);
}
// Inaccessible locally hosted file type, e.g. JSON, PDF, etc.
if (tabURL.length - tabURL.lastIndexOf('.') <= 5) {
info.appendChild($create('p', t('InaccessibleFileHint')));
}
document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild);
}
/** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */