Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomes77 authored Aug 22, 2023
1 parent 0dd0d60 commit d29a262
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
38 changes: 26 additions & 12 deletions autoconfirm&skip.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
function injectScript(YTNonstop, tag) {
policyDefault = trustedTypes.createPolicy('default', {
createHTML: string => string,
createScript: string => string
});

var node = document.getElementsByTagName(tag)[0];
var init_inject_script = document.createElement('script');
var run_inject_script = document.createElement('script');

init_inject_script.setAttribute('type', 'text/javascript');
run_inject_script.setAttribute('type', 'text/javascript');

init_inject_script.append(`YTNonstop = ${YTNonstop}()`);
const init_script = `YTNonstop = ${YTNonstop}()`;
init_inject_script.append(init_script);
node.appendChild(init_inject_script);

run_inject_script.append("autotube = YTNonstop = new YTNonstop();");
const run_script = "autotube = YTNonstop = new YTNonstop();";
run_inject_script.append(run_script);
node.appendChild(run_inject_script);

init_inject_script.remove();
Expand All @@ -26,8 +33,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 +120,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 +139,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
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "YT-Nonstop",
"version": "2.4.2",
"version": "2.4.3",
"description": "Deletes the annoying \"Video paused. Continue watching?\" popup on YouTube and keeps it running nonstop without autoplay message!",
"permissions": [ "declarativeContent", "storage", "tabs" ],
"host_permissions": [ "https://www.youtube.com/*", "https://music.youtube.com/*" ],
Expand Down

1 comment on commit d29a262

@Nomes77
Copy link
Owner Author

@Nomes77 Nomes77 commented on d29a262 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #11

Please sign in to comment.