9GAG Show Controls

Automatically adds the controls attribute to all video elements.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         9GAG Show Controls
// @namespace    http://www.diamonddownloads.weebly.net
// @version      0.1
// @locale       en-US
// @description  Automatically adds the controls attribute to all video elements.
// @author       RGSoftware, R.F Geraci
// @include      https://9gag.com/*
// @include      http://9gag.com/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @grant        none
// @icon         http://icons.iconarchive.com/icons/iconleak/stainless/256/script-icon.png
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    var scrollDiff = 500; //scrolled pixels


    var Tvideo = {
        oldHeight: $(window).scrollTop(),

        hasScrolled: function(amount){
            var height = $(window).scrollTop();
            //Covers boths scrolling up and scrolling down
            if (Math.abs((height - Tvideo.oldHeight)) >= amount){
                Tvideo.oldHeight = height;
                return true;
            }else{
                return false;
            }
        },
        showControls: function(){
            var v = $('video');

            for (var i=0;i<v.length;i++){
                v[i].setAttribute('controls', 'true');
            }
        },

        isVideos: function(){
            return $('video').length > 0;
        },
    };


    //Check onload for any video, 
    //from then when page scrolled

    if (Tvideo.isVideos){
        Tvideo.showControls();
    }

    $(window).scroll(function(){
        if (Tvideo.hasScrolled(scrollDiff)){

            if (Tvideo.isVideos){
                Tvideo.showControls();
            }

        }

    });


})();