Skip to content

Instantly share code, notes, and snippets.

@ihsoy-s
Created November 24, 2012 16:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihsoy-s/4140482 to your computer and use it in GitHub Desktop.
Save ihsoy-s/4140482 to your computer and use it in GitHub Desktop.
[greasemonkey] Disable Lazy Load Plugin
// ==UserScript==
// @name Disable_lazy_load
// @namespace https://gist.github.com/ihsoy-s/
// @version 0.2
// @description Remove lazy load
// @include http://*/*
// @include https://*/*
// @match http://*/*
// @match https://*/*
// @run-at document-end
// @copyright 2012, Yoshi-S
// ==/UserScript==
( function(){
// removeLazy
// elm: target element
// attr: attribute that contains real url of the image
function removeLazy (elm, attr) {
if( elm.getAttribute(attr) && elm.src != elm.getAttribute(attr) )
{
// copy real url
elm.src = elm.getAttribute(attr);
// remove original attribute
elm.removeAttribute(attr);
// debug message
console.debug("[Replace Lazy-load] Remove lazy-load:", elm.src);
}
}
// replaceLazyload
// doc: target
function replaceLazyload(doc) {
var img = doc.images;
var i;
if ( img != undefined )
{
for (i = 0; i < img.length; i++) {
// execute removeLazy function for each lazyload attributes
removeLazy(img[i], "data-lazy-src");
removeLazy(img[i], "data-original");
}
}
}
// event
function getEvent(evt){
var node = evt.target;
console.debug("[Replace Lazy-load] Get event:", evt.detail);
replaceLazyload(node);
}
// exec
replaceLazyload(document);
// exec if AutoPagerize was called
document.body.addEventListener('AutoPagerize_DOMNodeInserted', getEvent, false);
} () );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment