mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-22 18:19:59 +01:00
#1254 checkTabCS Changes
This commit is contained in:
parent
3ce4d7d458
commit
7171f5a900
@ -22,14 +22,20 @@ const setIcon = require('./setIcon');
|
||||
const dummyGetLocalStorage = require('./dummyGetLocalStorage');
|
||||
|
||||
const checkTabCS = async tabId => {
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
await dummyGetLocalStorage();
|
||||
let tabInfo;
|
||||
|
||||
if (!tabId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tabInfo = await browser.tabs.get(tabId);
|
||||
try {
|
||||
tabInfo = await browser.tabs.get(tabId);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tabUrl = tabInfo.url ? tabInfo.url : tabInfo.pendingUrl;
|
||||
const extUrl = browser.runtime.getURL('');
|
||||
let urlObj;
|
||||
@ -42,6 +48,7 @@ const checkTabCS = async tabId => {
|
||||
try {
|
||||
urlObj = new URL(tabUrl);
|
||||
} catch (e) {
|
||||
await setIcon(tabId, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ const onTabUpdated = async (tabID, changeInfo) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tabID && changeInfo.status === 'complete') {
|
||||
if (tabID && (changeInfo.status === 'complete' || changeInfo.favIconUrl || changeInfo.isArticle)) {
|
||||
await checkTabCS(tabID);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
import './styles/content_script.scss';
|
||||
const browser = require('webextension-polyfill');
|
||||
const { observe, createObserver } = require('./observer');
|
||||
const { getTabData, getInputs, addInputListener, portSetup } = require('./functions');
|
||||
const { getTabData, getInputs, addInputListener, portSetup, isInFrame } = require('./functions');
|
||||
const contentOnMessage = require('./events/contentOnMessage');
|
||||
const { loadFromLocalStorage, saveToLocalStorage } = require('../localStorage');
|
||||
const storeLog = require('../partials/storeLog');
|
||||
@ -63,7 +63,15 @@ const contentScriptRun = async () => {
|
||||
const mutationObserver = createObserver();
|
||||
observe(mutationObserver);
|
||||
|
||||
const onMessageListener = request => contentOnMessage(request, tabData);
|
||||
const onMessageListener = request => {
|
||||
if (request?.action === 'contentScript') {
|
||||
if (isInFrame()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return contentOnMessage(request, tabData);
|
||||
};
|
||||
browser.runtime.onMessage.addListener(onMessageListener);
|
||||
|
||||
window.addEventListener('beforeunload', async () => {
|
||||
|
@ -71,6 +71,10 @@ const contentOnMessage = async (request, tabData) => {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'contentScript': {
|
||||
return { status: 'ok' };
|
||||
}
|
||||
|
||||
default: {
|
||||
return { status: 'error' };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user