improve display while popup loads

This commit is contained in:
Ajay
2022-06-02 21:08:34 -04:00
parent 96173dd901
commit 3d9221eb8d
8 changed files with 43 additions and 45 deletions

View File

@@ -6,6 +6,7 @@ import { Message, MessageResponse, IsInfoFoundMessageResponse } from "./messageT
import { showDonationLink } from "./utils/configUtils";
import { AnimationUtils } from "./utils/animationUtils";
import { GenericUtils } from "./utils/genericUtils";
import { localizeHtmlPage } from "./utils/pageUtils";
const utils = new Utils();
interface MessageListener {
@@ -43,25 +44,20 @@ class MessageHandler {
}
}
let allowPopup = (window === window.top);
// To prevent clickjacking
window.onmessage = async e => {
if (e.source !== window.parent) return
let allowPopup = window === window.top;
window.addEventListener("message", async (e) => {
if (e.source !== window.parent) return;
if (e.origin.endsWith('.youtube.com')) return allowPopup = true;
await utils.wait(() => Config.config !== null);
if (Config.config.supportInvidious && e.origin.includes(Config.config.invidiousInstances)) return allowPopup = true;
}
});
//make this a function to allow this to run on the content page
async function runThePopup(messageListener?: MessageListener): Promise<void> {
if (window !== window.top) await utils.wait(() => allowPopup === true);
const messageHandler = new MessageHandler(messageListener);
localizeHtmlPage();
utils.localizeHtmlPage();
await utils.wait(() => Config.config !== null);
await utils.wait(() => Config.config !== null && allowPopup === true, 5000, 5);
document.querySelector("body").style.removeProperty("visibility");
type InputPageElements = {
whitelistToggle?: HTMLInputElement,