From abb4c05857a7baaf452e70754579b2c2505dc0b2 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 26 Oct 2020 20:30:50 +0100 Subject: [PATCH 1/4] #94 Prepared empty functionality module --- src/javascript/enhancements/anilyr.js | 10 ++++++++++ src/javascript/index.js | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 src/javascript/enhancements/anilyr.js diff --git a/src/javascript/enhancements/anilyr.js b/src/javascript/enhancements/anilyr.js new file mode 100644 index 0000000..d0cda71 --- /dev/null +++ b/src/javascript/enhancements/anilyr.js @@ -0,0 +1,10 @@ +import * as core from '../utils/aniwatchCore'; +import * as helper from '../utils/helpers'; + +export function init() { + core.registerScript(node => { + // run the scripts + + }, "^/anime/[0-9]*/[0-9]*$"); +} + diff --git a/src/javascript/index.js b/src/javascript/index.js index 9d86b8a..b58cb94 100644 --- a/src/javascript/index.js +++ b/src/javascript/index.js @@ -3,6 +3,7 @@ import { initCore } from './utils/aniwatchCore'; // helper import { initHelpers } from './utils/helpers'; // enhancements +import { init as anilyr } from './enhancements/anilyr'; import { init as animeRequests } from './enhancements/animeRequests'; import { init as languageDisplay } from './enhancements/languageDisplay'; import { init as quickSearch } from './enhancements/quickSearch'; @@ -14,6 +15,7 @@ initCore(); initHelpers(); // enhancements +anilyr(); animeRequests(); languageDisplay(); quickSearch(); \ No newline at end of file From f8b0dbbe3fc45937d22e7faedf2fd283365cb07a Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 26 Oct 2020 20:42:34 +0100 Subject: [PATCH 2/4] #94 Added empty observer for the player --- src/javascript/enhancements/anilyr.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/javascript/enhancements/anilyr.js b/src/javascript/enhancements/anilyr.js index d0cda71..76db373 100644 --- a/src/javascript/enhancements/anilyr.js +++ b/src/javascript/enhancements/anilyr.js @@ -1,10 +1,26 @@ import * as core from '../utils/aniwatchCore'; import * as helper from '../utils/helpers'; +const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip'; + export function init() { core.registerScript(node => { - // run the scripts - + if (helper.isHtmlElement(node) && node.id === SCREENSHOT_TOOLTIP_ID) { + observeScreenshotTooltip(node); + } }, "^/anime/[0-9]*/[0-9]*$"); } +function observeScreenshotTooltip(tooltip) { + let observer = new MutationObserver(mutations => { + mutations.forEach(mutation => { + + }); + }); + + observer.observe(tooltip, { + attributes: true, + attributeOldValue: true, + attributeFilter: ['style'], + }); +} \ No newline at end of file From 9ada3dbee6eec4d5a9ed0eab0680c58052fc2973 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 26 Oct 2020 20:46:03 +0100 Subject: [PATCH 3/4] #94 Detect closed tooltip --- src/javascript/enhancements/anilyr.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/javascript/enhancements/anilyr.js b/src/javascript/enhancements/anilyr.js index 76db373..dc6ecbf 100644 --- a/src/javascript/enhancements/anilyr.js +++ b/src/javascript/enhancements/anilyr.js @@ -14,7 +14,10 @@ export function init() { function observeScreenshotTooltip(tooltip) { let observer = new MutationObserver(mutations => { mutations.forEach(mutation => { - + // Switched to invisible + if(!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') { + console.log('SCREENSHOT TOOLTIP CLOSED'); + } }); }); From 4099841d4b705c3d761377bbff75e9d84aba402d Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 26 Oct 2020 20:52:51 +0100 Subject: [PATCH 4/4] #94 Detect player and resume video --- src/javascript/enhancements/anilyr.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/javascript/enhancements/anilyr.js b/src/javascript/enhancements/anilyr.js index dc6ecbf..f80ebd8 100644 --- a/src/javascript/enhancements/anilyr.js +++ b/src/javascript/enhancements/anilyr.js @@ -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 => { @@ -15,8 +16,11 @@ function observeScreenshotTooltip(tooltip) { let observer = new MutationObserver(mutations => { mutations.forEach(mutation => { // Switched to invisible - if(!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') { - console.log('SCREENSHOT TOOLTIP CLOSED'); + if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') { + let player = findPlayer(); + if(typeof player !== 'undefined'){ + resumePlayer(player); + } } }); }); @@ -24,6 +28,21 @@ function observeScreenshotTooltip(tooltip) { observer.observe(tooltip, { attributes: true, attributeOldValue: true, - attributeFilter: ['style'], + 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(); } \ No newline at end of file