GoogleGifs

Automatically plays gifs on google pages

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         GoogleGifs
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically plays gifs on google pages
// @author       Ian Pearce (@peeinears)
// @match        https://www.google.com/*
// @grant        MIT
// ==/UserScript==


// This script is originally from an extension called GoogleGifs by Ian Pearce, hence I have credited him as the author. I have merely turned it into a userscript because the extension was removed from Chrome's webstore.

(function() {
    'use strict';

    function playGIFs() {
        var els, i, a, img, matches, url;
        els = document.getElementsByClassName('rg_di');
        for (i = 0; i < els.length; i++) {
            if (els[i].animated) continue;
            els[i].animated = true;
            a = els[i].getElementsByTagName('a')[0];
            if (!a) continue;
            img = els[i].getElementsByTagName('img')[0];
            if (!img) continue;
            matches = a.href.match(/imgurl=(\S+?)(&|$)/i);
            if (matches !== null && matches.length > 1) {
                url = unescape(unescape(matches[1]));
                if (/\.gif(\?.*)?$/i.test(url)) {
                    img.src = url;
                }
            }
        }
  }

  // continue to load GIFs added to DOM after initial page load
  window.setInterval(playGIFs, 1000);
})();