touchup on observer logic

This commit is contained in:
Maxim Stewart 2020-05-16 01:19:12 -05:00
parent d845c9ce4f
commit 2fb39ce6ac
3 changed files with 25 additions and 17 deletions

View File

@ -11,11 +11,8 @@ Better YouTube + works to improve the YouTube experience by providing quick acce
* It shows volume level as you scroll. * It shows volume level as you scroll.
* It lets Unix, Linux, and MacOS systems have the ability to download the video using native app calls. * It lets Unix, Linux, and MacOS systems have the ability to download the video using native app calls.
# Version: 1.5.0 # Version: 1.5.1
* Refactored code. * Fixed observer logic.
* Resolved volume change not always sticking on Linux. (I think fixed...)
* Added a quick volume indicator when scrolling.
* Added NonStop watch mode.
# Download # Download
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/ https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Better Youtube +", "name": "Better Youtube +",
"version": "1.5.0", "version": "1.5.1",
"description": "Enhancements for Youtube to have a better experience.", "description": "Enhancements for Youtube to have a better experience.",
"applications": { "applications": {

View File

@ -45,10 +45,13 @@
let videoTimeLength, videoTimeCurent, ytRangeStart, ytRangeEnd, let videoTimeLength, videoTimeCurent, ytRangeStart, ytRangeEnd,
slugInputTag, endlessPlayTag, ytVideoIntervalLoop; slugInputTag, endlessPlayTag, ytVideoIntervalLoop;
let poppedContainer, videoSlug, volumeLbl, part; let poppedContainer, videoSlug, volumeLbl, part;
let loopingInterval = false; let modalHasBeenClosed = false;
let shouldHideVol = true; let loopingInterval = false;
let OSName = ""; // Default to false b/c if tag checked it sets this in setupProc and elsewhere.
let count = 0; let isEndlessWatch = false;
let shouldHideVol = true;
let OSName = "";
let count = 0;
// confirm dialog elm // confirm dialog elm
const isYoutubeMusic = window.location.hostname === 'music.youtube.com'; const isYoutubeMusic = window.location.hostname === 'music.youtube.com';
@ -63,13 +66,13 @@
const preSetupProc = () => { const preSetupProc = () => {
// Look to add saving image from video elm. // Look to add saving image from video elm.
// path = "/html/body/ytd-app/div/ytd-page-manager/ytd-watch-flexy/div[4]/div[1]/div/div[1]/div/div/div/ytd-player/div/div/div[1]/video" // path = "/html/body/ytd-app/div/ytd-page-manager/ytd-watch-flexy/div[4]/div[1]/div/div[1]/div/div/div/ytd-player/div/div/div[1]/video"
// elm = document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; // elm = document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (navigator.appVersion.indexOf("Win")!=-1) OSName = "Windows"; if (navigator.appVersion.indexOf("Win")!=-1) OSName = "Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName = "MacOS"; if (navigator.appVersion.indexOf("Mac")!=-1) OSName = "MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName = "UNIX"; if (navigator.appVersion.indexOf("X11")!=-1) OSName = "UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName = "Linux"; if (navigator.appVersion.indexOf("Linux")!=-1) OSName = "Linux";
// check if we've loaded elements already... // Check if we've loaded elements already...
if (!document.getElementById("slugCopyZone")) { if (!document.getElementById("slugCopyZone")) {
document.body.insertAdjacentHTML( 'beforeend', slugTemplate ); document.body.insertAdjacentHTML( 'beforeend', slugTemplate );
document.body.insertAdjacentHTML( 'beforeend', menuTemplate ); document.body.insertAdjacentHTML( 'beforeend', menuTemplate );
@ -161,6 +164,7 @@
// Start observing the target node for configured mutations // Start observing the target node for configured mutations
if (endlessPlayTag.checked == true) { if (endlessPlayTag.checked == true) {
endlessPlayTag.setAttribute("checked", true); endlessPlayTag.setAttribute("checked", true);
isEndlessWatch = true;
console.log("Endless play checked. Starting observer..."); console.log("Endless play checked. Starting observer...");
observer2.observe(document, observerConfig2); observer2.observe(document, observerConfig2);
} }
@ -173,10 +177,16 @@
if (mutation.type === 'attributes') { if (mutation.type === 'attributes') {
controlManager(mutation.target); controlManager(mutation.target);
} else if (mutation.type === 'childList') { } else if (mutation.type === 'childList') {
let elm = document.querySelector(dialogElementQueryRef).parentElement; if (isEndlessWatch) {
elmDisplayState = elm.style.display; let elm = document.querySelector(dialogElementQueryRef).parentElement;
if (elmDisplayState !== 'none') { elmDisplayState = elm.style.display;
clickDialog(); if (elmDisplayState !== 'none' && !modalHasBeenClosed) {
clickDialog();
modalHasBeenClosed = true;
setTimeout(function () {
modalHasBeenClosed = false;
}, 5000);
}
} }
} }
} }
@ -205,14 +215,15 @@
isChecked = endlessPlayTag.getAttribute("checked"); isChecked = endlessPlayTag.getAttribute("checked");
if (isChecked) { if (isChecked) {
endlessPlayTag.setAttribute("checked", false); endlessPlayTag.setAttribute("checked", false);
isEndlessWatch = false;
console.log("Stopping endless play..."); console.log("Stopping endless play...");
observer2.disconnect(); observer2.disconnect();
} else { } else {
endlessPlayTag.setAttribute("checked", true); endlessPlayTag.setAttribute("checked", true);
isEndlessWatch = true;
console.log("Starting endless play..."); console.log("Starting endless play...");
observer2.observe(confirmDialogElement, observerConfig2); observer2.observe(confirmDialogElement, observerConfig2);
} }
console.log(observer2);
} }
const showThumbImageVew = (e) => { const showThumbImageVew = (e) => {