moved the EventListener to the settings and delted the function for it

This commit is contained in:
kaffem 2021-02-06 23:08:53 +01:00
parent 6d91dde44b
commit a01a7a8392

View file

@ -24,7 +24,7 @@ export function init(): void {
getGlobalConfiguration().getProperty(SETTINGS_playerAutopauseAfterFocusLost, value => { getGlobalConfiguration().getProperty(SETTINGS_playerAutopauseAfterFocusLost, value => {
if (value) { if (value) {
core.registerScript((node: Node) => { core.registerScript((node: Node) => {
addVisibilityChangeListener(); window.addEventListener('visibilitychange', observeTabFocus, false);
}, "^/anime/[0-9]*/[0-9]*$"); }, "^/anime/[0-9]*/[0-9]*$");
} }
}); });
@ -54,10 +54,6 @@ function observeScreenshotTooltip(tooltip: HTMLElement): void {
}); });
} }
function addVisibilityChangeListener(): void{
window.addEventListener('visibilitychange', observeTabFocus, false);
}
function observeTabFocus(): void { function observeTabFocus(): void {
let docState = document.visibilityState; let docState = document.visibilityState;
let playerElement = findPlayerElement(); let playerElement = findPlayerElement();