-
-
Save noromanba/d6401655958f3d553589 to your computer and use it in GitHub Desktop.
immediately load images w/ PagerExtention for UserScript
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 Load Image Immediately | |
// @namespace http://noromanba.flavors.me | |
// @description immediately load images w/ PagerExtention for UserScript | |
// @include http://gigazine.net/* | |
// @include http://www.moae.jp/comic/* | |
// @grant none | |
// @run-at document-end | |
// @version 2014.9.21.1 | |
// @homepage https://gist.github.com/noromanba/d6401655958f3d553589 | |
// @downloadURL https://gist.github.com/noromanba/d6401655958f3d553589/raw/g-lii.user.js | |
// @contributor to https://gist.github.com/to/5334394 | |
// @org-license Unknown (as-is) | |
// @author noromanba http://noromanba.flavors.me | |
// @license TBD (as-is) | |
// @icon http://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Toilet_paper_roll_revisited.svg/32px-Toilet_paper_roll_revisited.svg.png | |
// @icon64 http://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Toilet_paper_roll_revisited.svg/64px-Toilet_paper_roll_revisited.svg.png | |
// ==/UserScript== | |
// Icon (CC0 by PeterM) | |
// http://commons.wikimedia.org/wiki/File:Toilet_paper_roll_revisited.svg | |
// Devel | |
// https://gist.github.com/noromanba/d6401655958f3d553589 | |
(function() { | |
// c.f. jQuery.lazyload | |
// http://www.appelsiini.net/projects/lazyload | |
// https://github.com/tuupola/jquery_lazyload | |
var loadImmediate = function(ctx) { | |
ctx = ctx || document; | |
Array.prototype.forEach.call(ctx.querySelectorAll('img.lazy'), function(img) { | |
img.src = img.dataset.original; | |
}); | |
}; | |
loadImmediate(); | |
[ | |
'AutoPatchWork.DOMNodeInserted', | |
'AutoPagerize_DOMNodeInserted', | |
'AutoPagerAfterInsert' | |
].forEach(function(insert) { | |
// TODO debounce / MutationObserver | |
document.body.addEventListener(insert, function(evt) { | |
loadImmediate(evt.target); | |
}, false); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment