9gag Auto Gif Controls

Shows the gif/mp4 controls automatically

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);