Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomes77 committed Aug 22, 2023
1 parent 92dba6c commit 7e9cf6f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ let YTNonstop = (function YTNonstop(options) {
}
const YTMusic = window.location.hostname === 'music.youtube.com';
const videoPlayer = document.getElementById('movie_player');
const miniPlayer = YTMusic ? document.querySelector('ytmusic-player-bar:not([player-page-open_])') :
document.querySelector('ytd-app[miniplayer-is-active]');

function getTimestamp() {
return new Date().toLocaleTimeString();
Expand Down Expand Up @@ -115,7 +113,7 @@ let YTNonstop = (function YTNonstop(options) {

const loadSettings = {
setSettings: setInterval(() => {
if (window.location.href.indexOf("/watch") == -1 | !miniPlayer) return;
if (window.location.href.indexOf("/watch") == -1) return;

// set play button observer
try {
Expand All @@ -134,23 +132,32 @@ let YTNonstop = (function YTNonstop(options) {
}, 1000),

setAutonavButton: setInterval(() => {
if (window.location.href.indexOf("/watch") == -1 | !miniPlayer) return;
if (window.location.href.indexOf("/watch") == -1) {
if (document.querySelector('ytd-app[miniplayer-is-active]') || document.querySelector('ytmusic-player-bar:not([player-page-open_])')) {
autonav_button();
} else {
return;
}
}
autonav_button();
}, 5000),

// Autoplay Method 1: Set last time active all 20 minutes to now
// Autoplay Method 2: If video paused and popup visible ---> play video
// Autoplay Method 3: Pause and UnPause after 20 minutes
setOtherMethods: setInterval(() => {
if (window.location.href.indexOf("/watch") == -1 | !miniPlayer) return;
if (window.location.href.indexOf("/watch") == -1) {
if (document.querySelector('ytd-app[miniplayer-is-active]') || document.querySelector('ytmusic-player-bar:not([player-page-open_])')) {
window._lact = Date.now();
log('Reset last time active');
play();
} else {
return;
}
}
window._lact = Date.now();
log('Reset last time active');
play();
// if (videoPlayer.getPlayerState() === 1) {
// videoPlayer.pauseVideo();
// videoPlayer.playVideo();
// log('Paused and unpaused video');
// }
}, 600000)
}

Expand Down

0 comments on commit 7e9cf6f

Please sign in to comment.