Last active
March 25, 2026 20:01
-
-
Save sandorex/481e4897bd816faeb010dcaf1ca88224 to your computer and use it in GitHub Desktop.
Violetmonkey script for playing audio only on youtube music
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Youtube Music Audio Only | |
| // @match https://music.youtube.com/watch* | |
| // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAllBMVEUAAAD/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/ADP/BDb/F0X/GUf/fZf/zNb/+/z/+vv/AzX/fJb/9ff/rb3/UXT/DT3/u8n/0Nn/L1n/tMP/Cjv/dpH/Bjj/IE3/////2+L/THD/t8X/KFP/jaT/Dz//6e3/ZIP/AjX/J1L/GEaLdxWzAAAAEXRSTlMAE2Ok0vP/Lqf6DZf+K9s48eoeiQYAAAEHSURBVHgBhZMDYgNREIbf6k+ytq1a9z9cMat6vjhjiQNJVlQN0FRFlsRPTucLdi7n0zexbpj4gmnon+WWjR/Y1iF3XPyC6+z2h9zzfe/QWH3om/8gjOIkiaMw2KIseRgg0iwvSh/wyyLPUhAG1bfkX9VNi5W2qaullo9qz4t93fXY6bt68XEWQlr6kzWLfNNosqVjkpCX/PL2430Y9yj5kqksFPoMi4/3ab66xkoR0ociVPqMykVhnm9uQZQRfahCo/7E/qYwx3f3eMePqWOaAP1KsCgQD49PABKyAa/AhfiZ5PO3JNkyPzfq5bdGsa1mh8WPm10YfuXYpeXXnj8c7vSY42XO/w21OiejUnjSMgAAAABJRU5ErkJggg== | |
| // @homepageURL https://gist.github.com/sandorex/481e4897bd816faeb010dcaf1ca88224 | |
| // @downloadURL https://gist.github.com/sandorex/481e4897bd816faeb010dcaf1ca88224/raw/d7961daccaf89ec3dc910ea98e0be45f58be985b/yt-music-audio-only.user.js | |
| // @grant none | |
| // @run-at document-idle | |
| // @version 1.0 | |
| // @author Sandorex | |
| // @description Play music only on youtube music | |
| // ==/UserScript== | |
| window.trustedTypes.createPolicy('default', { createHTML: (s, sink) => s, createScriptURL: (s, type, sink) => s, createScript: (s, type, sink) => s, emptyScript: (sink) => sink, }); | |
| (function(){ | |
| setTimeout(() => { | |
| // find the video element | |
| var video = document.querySelector("video"); | |
| if (video === undefined || video === null) { | |
| alert("Error querying for video element"); | |
| } | |
| // TODO check for errors | |
| // copy the element data into the audio | |
| var audio = document.createElement("audio"); | |
| audio.innerHTML = video.innerHTML; | |
| // replace the video element with audio | |
| video.replaceWith(audio); | |
| // this will automatically play it but how do i know if it was playing? | |
| // document.querySelector('[aria-label="Pause"]').click(); | |
| }, 2000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment