Last active
October 1, 2021 08:52
-
-
Save mdrokz/728f8ad0eca1d7ff48275f90d451a0ab to your computer and use it in GitHub Desktop.
Vivaldi userscript that can remove video and add custom slider to youtube music for web panel usage
This file contains 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 Volume Slider | |
// @description Custom volume slider for youtube music. | |
// @author mdrokz | |
// @match https://music.youtube.com/* | |
// @version 2.6 | |
// ==/UserScript== | |
(function() { | |
const interval = setInterval(() => { | |
let video = document.getElementsByTagName('video')[0]; | |
if(video) { | |
video.remove(); | |
clearInterval(interval); | |
} | |
},2000); | |
let custom_slider = document.createElement('input'); | |
// set properties | |
custom_slider.type = "range"; | |
custom_slider.min = "0"; | |
custom_slider.max = "100"; | |
custom_slider.id = "custom-slider"; | |
custom_slider.defaultValue = "40"; | |
custom_slider.style.width = "30%"; | |
custom_slider.onchange = function(e) { | |
let slider = document.getElementById("volume-slider"); | |
let value = parseInt(e.target.value); | |
slider.value = value; | |
slider.dispatchEvent(new Event('change')); | |
}; | |
let element = document.getElementsByClassName('ytmusic-player-page')[0]; | |
element.insertBefore(custom_slider,element.children[1]); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
drag and drop the script into vivaldi extensions and it will be used whenever you visit youtube music