Skip to content

Instantly share code, notes, and snippets.

@marcinantkiewicz
Last active November 5, 2021 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinantkiewicz/0f691a69d9aaf140ae0234c76f11a175 to your computer and use it in GitHub Desktop.
Save marcinantkiewicz/0f691a69d9aaf140ae0234c76f11a175 to your computer and use it in GitHub Desktop.
// userscript parts to pause playback in all open tabs, save for the current one.
// handles http video and audio tags, this will pause what is playing.
// Swap pause() to play() to reverse. Other controls:
// .volume (goes on interval from 0-1.0)
// .muted (bool)
['video','audio'].forEach((tag)=>{
player = document.getElementsByTagName(tag)
if(!![...player].find((e)=>e && !(e.paused && e.ended && e.muted))){
player[0].pause()
}
})
// storage - session/localStorage for same domain, else GM_setValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment