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,27 +170,29 @@ 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) {
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
if (retryCountdown > 0 && (
tab.status !== 'complete' ||
FIREFOX && tab.url === ABOUT_BLANK)) {
setTimeout(ping, 100, tab, --retryCountdown);
return;
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')));
}
if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) {
} else if (isStore) {
$('label', info).textContent = t('unreachableAMO');
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
@ -214,8 +216,6 @@ function initPopup(frames) {
}
document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild);
});
});
}
/** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */