mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 14:07:13 +03:00
improve display while popup loads
This commit is contained in:
20
src/popup.ts
20
src/popup.ts
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user