Feature/#94 auto resume after screenshot #101
|
@ -2,6 +2,7 @@ import * as core from '../utils/aniwatchCore';
|
|||
import * as helper from '../utils/helpers';
|
||||
|
||||
const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip';
|
||||
const PLAYER_ID = 'player';
|
||||
|
||||
export function init() {
|
||||
core.registerScript(node => {
|
||||
|
@ -16,7 +17,10 @@ function observeScreenshotTooltip(tooltip) {
|
|||
mutations.forEach(mutation => {
|
||||
// Switched to invisible
|
||||
if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') {
|
||||
console.log('SCREENSHOT TOOLTIP CLOSED');
|
||||
let player = findPlayer();
|
||||
if(typeof player !== 'undefined'){
|
||||
resumePlayer(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -27,3 +31,18 @@ function observeScreenshotTooltip(tooltip) {
|
|||
attributeFilter: ['style'],
|
||||
});
|
||||
}
|
||||
|
||||
function findPlayer() {
|
||||
const PLAYER_TAG_NAME = 'VIDEO'; // tagName gives UpperCase
|
||||
|
||||
let playerCandidate = document.getElementById(PLAYER_ID);
|
||||
if (playerCandidate.tagName === PLAYER_TAG_NAME) {
|
||||
return playerCandidate;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resumePlayer(player) {
|
||||
player.play();
|
||||
}
|
Loading…
Reference in a new issue