Skip to content

Instantly share code, notes, and snippets.

@D4niloMR
Last active January 7, 2024 08:57
Show Gist options
  • Save D4niloMR/70b7369050ef8822d9b80d994a09fb33 to your computer and use it in GitHub Desktop.
Save D4niloMR/70b7369050ef8822d9b80d994a09fb33 to your computer and use it in GitHub Desktop.
/// ytstayactive.js
// ==UserScript==
// @name YouTube - Stay Active and Play Forever
// @namespace q1k
// @version 3.1.1
// @description Tired of Youtube pausing playback asking you to click 'yes' to continue playing? This script will make the popup never appear, music will never stop. Never pause, never inactive, never worry. The script will keep you active and keep playing music FOREVER. Enables playing in background on mobile.
// @author q1k
// ==/UserScript==
Object.defineProperties(document, { /*'hidden': {value: false},*/ 'webkitHidden': {value: false}, 'visibilityState': {value: 'visible'}, 'webkitVisibilityState': {value: 'visible'} });
setInterval(function(){
document.dispatchEvent( new KeyboardEvent( 'keyup', { bubbles: true, cancelable: true, keyCode: 143, which: 143 } ) );
}, 60000);
@bananaTiko
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment