Mutation observer added plus cs cleanup
This commit is contained in:
parent
d2509adf68
commit
faed6edee5
|
@ -9,8 +9,9 @@ Better YouTube + works to improve the YouTube experience by providing quick acce
|
||||||
* It allows for quick access to the YouTube video slug.
|
* It allows for quick access to the YouTube video slug.
|
||||||
* It lets Unix, Linux, and MacOS systems the ability to download the video using native app calls.
|
* It lets Unix, Linux, and MacOS systems the ability to download the video using native app calls.
|
||||||
|
|
||||||
# Version: 1.4.0
|
# Version: 1.4.3
|
||||||
Updating for Firefox AMO
|
* Added mutation observation for (un)fullscreen action.
|
||||||
|
* Cleaned up some log cruft and fixed CSS...
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/
|
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let OSName = "";
|
let OSName = "";
|
||||||
|
|
||||||
|
// Options for the observer (which mutations to observe)
|
||||||
|
const config = { attributes: true };
|
||||||
|
|
||||||
|
|
||||||
const preSetupProc = () => {
|
const preSetupProc = () => {
|
||||||
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";
|
||||||
|
@ -117,7 +121,14 @@
|
||||||
ytFloatBttn.addEventListener("click", toggleFloat);
|
ytFloatBttn.addEventListener("click", toggleFloat);
|
||||||
ytDownloadBttn.addEventListener("click", downloadVideo);
|
ytDownloadBttn.addEventListener("click", downloadVideo);
|
||||||
video.addEventListener("wheel", manageVolume);
|
video.addEventListener("wheel", manageVolume);
|
||||||
video.addEventListener("dblclick", controlManager);
|
|
||||||
|
// Observer target for fullscreen action...
|
||||||
|
targetNode = document.getElementsByTagName('ytd-app')[0];
|
||||||
|
|
||||||
|
// Create an observer instance linked to the callback function
|
||||||
|
const observer = new MutationObserver(mutationcallback);
|
||||||
|
// Start observing the target node for configured mutations
|
||||||
|
observer.observe(targetNode, config);
|
||||||
|
|
||||||
// Dragable window for floating video
|
// Dragable window for floating video
|
||||||
dragVideo(poppedContainer);
|
dragVideo(poppedContainer);
|
||||||
|
@ -161,16 +172,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
const controlManager = () => {
|
// Callback function to execute when mutations are observed
|
||||||
setTimeout(function () {
|
const mutationcallback = (mutationsList, observer) => {
|
||||||
if (window.innerHeight !== screen.height) {
|
for(let mutation of mutationsList) {
|
||||||
|
if (mutation.type === 'attributes') {
|
||||||
|
controlManager(mutation.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const controlManager = (elm) => {
|
||||||
|
attrib = elm.getAttribute('masthead-hidden_');
|
||||||
|
if (attrib == null) { // if out of fullscreen
|
||||||
ytEnhancerMenu.style.display = "block";
|
ytEnhancerMenu.style.display = "block";
|
||||||
slugInputTag.style.display = "block";
|
slugInputTag.style.display = "block";
|
||||||
} else {
|
} else { // if fullscreen
|
||||||
ytEnhancerMenu.style.display = "none";
|
ytEnhancerMenu.style.display = "none";
|
||||||
slugInputTag.style.display = "none";
|
slugInputTag.style.display = "none";
|
||||||
}
|
}
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadVideo = () => {
|
const downloadVideo = () => {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
left: 35%;
|
left: 35%;
|
||||||
width: 10em;
|
width: 10em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#enhancerMenuIDRef, #slugCopyZone {
|
#enhancerMenuIDRef, #slugCopyZone {
|
||||||
|
|
Loading…
Reference in New Issue