From 67996869cbaf4590707b23a4aced7d288c08689f Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Sat, 16 May 2020 16:19:24 -0500 Subject: [PATCH] actualkly fixed observer logic --- README.md | 4 ++-- src/manifest.json | 2 +- src/scripts/betterYoutube.js | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 35d2975..76433c3 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Better YouTube + works to improve the YouTube experience by providing quick acce * 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. -# Version: 1.5.1 -* Fixed observer logic. +# Version: 1.5.2 +* Actually fixed observer logic. # Download https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/ diff --git a/src/manifest.json b/src/manifest.json index 1e0cc74..ac8dde3 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Better Youtube +", - "version": "1.5.1", + "version": "1.5.2", "description": "Enhancements for Youtube to have a better experience.", "applications": { diff --git a/src/scripts/betterYoutube.js b/src/scripts/betterYoutube.js index ca96889..e84351f 100644 --- a/src/scripts/betterYoutube.js +++ b/src/scripts/betterYoutube.js @@ -163,8 +163,7 @@ observer2 = new MutationObserver(mutationCallback); // Start observing the target node for configured mutations if (endlessPlayTag.checked == true) { - endlessPlayTag.setAttribute("checked", true); - isEndlessWatch = true; + this.isEndlessWatch = true; console.log("Endless play checked. Starting observer..."); observer2.observe(document, observerConfig2); } @@ -177,12 +176,12 @@ if (mutation.type === 'attributes') { controlManager(mutation.target); } else if (mutation.type === 'childList') { - if (isEndlessWatch) { + if (this.isEndlessWatch) { let elm = document.querySelector(dialogElementQueryRef).parentElement; elmDisplayState = elm.style.display; - if (elmDisplayState !== 'none' && !modalHasBeenClosed) { - clickDialog(); + if (elmDisplayState !== 'none' && modalHasBeenClosed == false) { modalHasBeenClosed = true; + clickDialog(); setTimeout(function () { modalHasBeenClosed = false; }, 5000); @@ -212,15 +211,14 @@ } const toggleEndlessPlay = () => { - isChecked = endlessPlayTag.getAttribute("checked"); - if (isChecked) { + if (this.isEndlessWatch) { endlessPlayTag.setAttribute("checked", false); - isEndlessWatch = false; + this.isEndlessWatch = false; console.log("Stopping endless play..."); observer2.disconnect(); } else { endlessPlayTag.setAttribute("checked", true); - isEndlessWatch = true; + this.isEndlessWatch = true; console.log("Starting endless play..."); observer2.observe(confirmDialogElement, observerConfig2); }