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; 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;
} }

View File

@ -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,27 +170,29 @@ 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 => {
if (pong) {
return; 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 // 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 // so we'll wait a bit to handle popup being invoked right after switching
if (retryCountdown > 0 && ( await new Promise(resolve => setTimeout(resolve, 100));
tab.status !== 'complete' ||
FIREFOX && tab.url === ABOUT_BLANK)) {
setTimeout(ping, 100, tab, --retryCountdown);
return;
} }
const info = t.template.unreachableInfo; const info = t.template.unreachableInfo;
if (!FIREFOX) { if (!FIREFOX) {
// Chrome "Allow access to file URLs" in chrome://extensions message // Chrome "Allow access to file URLs" in chrome://extensions message
info.appendChild($create('p', t('unreachableFileHint'))); info.appendChild($create('p', t('unreachableFileHint')));
} } else if (isStore) {
if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) {
$('label', info).textContent = t('unreachableAMO'); $('label', info).textContent = t('unreachableAMO');
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) + const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
(FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF')); (FIREFOX < 60 ? '' : '\n' + t('unreachableAMOHintNewFF'));
@ -214,8 +216,6 @@ function initPopup(frames) {
} }
document.body.classList.add('unreachable'); document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild); document.body.insertBefore(info, document.body.firstChild);
});
});
} }
/** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */ /** @param {chrome.webNavigation.GetAllFrameResultDetails} frame */