Skip to content

Instantly share code, notes, and snippets.

@noromanba
Forked from to/g-lii.user.js
Last active June 20, 2020 23:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noromanba/d6401655958f3d553589 to your computer and use it in GitHub Desktop.
Save noromanba/d6401655958f3d553589 to your computer and use it in GitHub Desktop.
immediately load images w/ PagerExtention for UserScript
// ==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