9gag Auto Gif Controls

Shows the gif/mp4 controls automatically

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           9gag Auto Gif Controls
// @namespace      http://www.diamonddownloads.weebly.com
// @version        1.3
// @description    Shows the gif/mp4 controls automatically
// @author         RF Geraci
// @include        *9gag.com*
// @grant          none
// @run-at         document-body
// ==/UserScript==

gag = {

    init : function(t){

       setInterval(function(){

            var classN = "badge-animated-container-animated post-view"; //Default
            var winLoc = window.location.href;

            var pages =["hot", "trending", "fresh"];

            for (var o = 0; o<pages.length; o++){

                if (winLoc.indexOf(pages[o]) > -1 || document.getElementsByClassName('badge-animated-container-animated').length > 0){
                    classN = "badge-animated-container-animated"; //Change var if these pages are open
                    break;
                }
            }

            var ele = document.getElementsByClassName(classN);

            for(var i=0; i<ele.length; i++){

                var c  = ele[i].childNodes[1];

                if (!c.hasAttribute('controls')){
                    console.log("[9GAG AUTO GIF CONTROLS] -> Added Control attribute to " + ele[i].className + " (inst " + i + ")");
                    c.setAttribute("controls", "");
                }
            }     

        }, t);
    }

};

gag.init(1000);