Greasy Fork is available in English.

HindustanTimes - fetch lazy-load images immediately

Fetch lazy-load images immediately at document load

Version au 02/05/2015. Voir la dernière version.

// ==UserScript==
// @name        HindustanTimes - fetch lazy-load images immediately
// @description Fetch lazy-load images immediately at document load
// @include     http://www.hindustantimes.com/*
// @version     1.0
// @namespace   wOxxOm.scripts
// @author      wOxxOm
// @run-at      document-start
// ==/UserScript==

setMutationHandler(document, 'img.lazy', function(observer, nodes) {
  for (var i=0, len=nodes.length, n; i<len && (n=nodes[i]); i++) {
    n.src = n.dataset.original;
    n.classList.remove('lazy');
  }
  return true;
});

function setMutationHandler(baseNode, selector, cb) {
  var ob = new MutationObserver(function(mutations){
    for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++)
      for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++)
        if (n.nodeType == 1)
          if ((n = n.matches(selector) ? [n] : n.querySelectorAll(selector)) && n.length)
            if (!cb(ob, n))
              return;
  });
  ob.observe(baseNode, {subtree:true, childList:true}); 
}