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,7 +45,10 @@
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 modalHasBeenClosed = false;
let loopingInterval = false; let loopingInterval = false;
// Default to false b/c if tag checked it sets this in setupProc and elsewhere.
let isEndlessWatch = false;
let shouldHideVol = true; let shouldHideVol = true;
let OSName = ""; let OSName = "";
let count = 0; let count = 0;
@ -69,7 +72,7 @@
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') {
if (isEndlessWatch) {
let elm = document.querySelector(dialogElementQueryRef).parentElement; let elm = document.querySelector(dialogElementQueryRef).parentElement;
elmDisplayState = elm.style.display; elmDisplayState = elm.style.display;
if (elmDisplayState !== 'none') { if (elmDisplayState !== 'none' && !modalHasBeenClosed) {
clickDialog(); 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) => {