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 lets Unix, Linux, and MacOS systems have the ability to download the video using native app calls.
# Version: 1.5.0
* Refactored code.
* Resolved volume change not always sticking on Linux. (I think fixed...)
* Added a quick volume indicator when scrolling.
* Added NonStop watch mode.
# Version: 1.5.1
* Fixed observer logic.
# Download
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/

View File

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

View File

@ -45,10 +45,13 @@
let videoTimeLength, videoTimeCurent, ytRangeStart, ytRangeEnd,
slugInputTag, endlessPlayTag, ytVideoIntervalLoop;
let poppedContainer, videoSlug, volumeLbl, part;
let loopingInterval = false;
let shouldHideVol = true;
let OSName = "";
let count = 0;
let modalHasBeenClosed = 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 OSName = "";
let count = 0;
// confirm dialog elm
const isYoutubeMusic = window.location.hostname === 'music.youtube.com';
@ -63,13 +66,13 @@
const preSetupProc = () => {
// 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"
// 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("Mac")!=-1) OSName = "MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName = "UNIX";
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")) {
document.body.insertAdjacentHTML( 'beforeend', slugTemplate );
document.body.insertAdjacentHTML( 'beforeend', menuTemplate );
@ -161,6 +164,7 @@
// Start observing the target node for configured mutations
if (endlessPlayTag.checked == true) {
endlessPlayTag.setAttribute("checked", true);
isEndlessWatch = true;
console.log("Endless play checked. Starting observer...");
observer2.observe(document, observerConfig2);
}
@ -173,10 +177,16 @@
if (mutation.type === 'attributes') {
controlManager(mutation.target);
} else if (mutation.type === 'childList') {
let elm = document.querySelector(dialogElementQueryRef).parentElement;
elmDisplayState = elm.style.display;
if (elmDisplayState !== 'none') {
clickDialog();
if (isEndlessWatch) {
let elm = document.querySelector(dialogElementQueryRef).parentElement;
elmDisplayState = elm.style.display;
if (elmDisplayState !== 'none' && !modalHasBeenClosed) {
clickDialog();
modalHasBeenClosed = true;
setTimeout(function () {
modalHasBeenClosed = false;
}, 5000);
}
}
}
}
@ -205,14 +215,15 @@
isChecked = endlessPlayTag.getAttribute("checked");
if (isChecked) {
endlessPlayTag.setAttribute("checked", false);
isEndlessWatch = false;
console.log("Stopping endless play...");
observer2.disconnect();
} else {
endlessPlayTag.setAttribute("checked", true);
isEndlessWatch = true;
console.log("Starting endless play...");
observer2.observe(confirmDialogElement, observerConfig2);
}
console.log(observer2);
}
const showThumbImageVew = (e) => {