Last active
May 24, 2020 11:07
-
-
Save xtotdam/ac5398500d10da27941c9650e521158f to your computer and use it in GitHub Desktop.
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 9gag volume and controls | |
// @namespace https://greasyfork.org/en/scripts/382093 | |
// @match https://9gag.com/* | |
// @run-at document-start | |
// @grant none | |
// @version 1.1 | |
// @description Adds the controls to the videos ("gifs") and sets the default volume to 30% | |
// @author Artain | |
// @author xtotdam | |
// @homepageURL https://greasyfork.org/en/scripts/382093 | |
// @homepageURL https://gist.github.com/xtotdam/ac5398500d10da27941c9650e521158f | |
// @license https://creativecommons.org/licenses/by-sa/4.0/ | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function changeVid(mutationsList, observer){ | |
var vids = document.querySelectorAll("video:not(.alreadyChanged)"); | |
for(var i=0; i < vids.length; ++i) { | |
var v = vids[i]; | |
v.volume = 0.3; | |
v.setAttribute("class", "alreadyChanged"); | |
v.setAttribute("controls", ""); | |
} | |
var sounds = document.querySelectorAll(".sound-toggle"); | |
for(var i=0; i<sounds.length; i++){ | |
sounds[i].setAttribute("hidden", true); | |
} | |
var elems = document.querySelectorAll(".length"); | |
for(var i=0; i<elems.length; i++){ | |
elems[i].setAttribute("hidden", true); | |
} | |
} | |
window.addEventListener("load", function(event) { | |
changeVid(false,false); | |
var observer = new MutationObserver(changeVid); | |
observer.observe(document.getElementById("list-view-2"), {subtree: true, childList: true}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment