Created
November 24, 2012 16:52
-
-
Save ihsoy-s/4140482 to your computer and use it in GitHub Desktop.
[greasemonkey] Disable Lazy Load Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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