actualkly fixed observer logic

This commit is contained in:
Maxim Stewart 2020-05-16 16:19:24 -05:00
parent 2fb39ce6ac
commit 67996869cb
3 changed files with 10 additions and 12 deletions

View File

@ -11,8 +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.1 # Version: 1.5.2
* Fixed observer logic. * Actually fixed observer logic.
# 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.1", "version": "1.5.2",
"description": "Enhancements for Youtube to have a better experience.", "description": "Enhancements for Youtube to have a better experience.",
"applications": { "applications": {

View File

@ -163,8 +163,7 @@
observer2 = new MutationObserver(mutationCallback); observer2 = new MutationObserver(mutationCallback);
// 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); this.isEndlessWatch = 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);
} }
@ -177,12 +176,12 @@
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) { if (this.isEndlessWatch) {
let elm = document.querySelector(dialogElementQueryRef).parentElement; let elm = document.querySelector(dialogElementQueryRef).parentElement;
elmDisplayState = elm.style.display; elmDisplayState = elm.style.display;
if (elmDisplayState !== 'none' && !modalHasBeenClosed) { if (elmDisplayState !== 'none' && modalHasBeenClosed == false) {
clickDialog();
modalHasBeenClosed = true; modalHasBeenClosed = true;
clickDialog();
setTimeout(function () { setTimeout(function () {
modalHasBeenClosed = false; modalHasBeenClosed = false;
}, 5000); }, 5000);
@ -212,15 +211,14 @@
} }
const toggleEndlessPlay = () => { const toggleEndlessPlay = () => {
isChecked = endlessPlayTag.getAttribute("checked"); if (this.isEndlessWatch) {
if (isChecked) {
endlessPlayTag.setAttribute("checked", false); endlessPlayTag.setAttribute("checked", false);
isEndlessWatch = false; this.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; this.isEndlessWatch = true;
console.log("Starting endless play..."); console.log("Starting endless play...");
observer2.observe(confirmDialogElement, observerConfig2); observer2.observe(confirmDialogElement, observerConfig2);
} }