Greasy Fork

Greasy Fork is available in English.

9gag volume and controls

Adds the controls to the videos ("gifs") and sets the default volume to 30%

目前为 2019-04-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         9gag volume and controls
// @namespace    http://greasyfork.icu/en/scripts/382093
// @match        https://9gag.com/*
// @run-at       document-start
// @grant        none
// @version      1.0.1
// @description  Adds the controls to the videos ("gifs") and sets the default volume to 30%
// @author       Artain
// @homepageURL  http://greasyfork.icu/en/scripts/382093
// @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", "")
        }
    }
    
    window.addEventListener("load", function(event) {
        changeVid(false,false);
        var observer = new MutationObserver(changeVid);

        observer.observe(document.getElementById("list-view-2"), {subtree: true, childList: true});
    });
})();