Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created July 23, 2008 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hotchpotch/1943 to your computer and use it in GitHub Desktop.
Save hotchpotch/1943 to your computer and use it in GitHub Desktop.
Autopagerize for haiku
// ==UserScript==
// @name Autopagerize for haiku
// @namespace http://rails2u.com/
// @include http://h.hatena.ne.jp/*
// @include http://h.hatena.com/*
// ==/UserScript==
var THRESHOLD = 800;
var w = unsafeWindow;
var p = w.Hatena.Haiku.Pager;
var Ten = w.Ten;
var enable = true;
var appending = false;
var lastMaxScrollY = 0;
var now = function() {
return Number(new Date);
};
p.addEventListener('loadedEntries', function() {
appending = false;
});
w.addEventListener('scroll', function(ev) {
if (!enable) return;
if (!appending) {
if ((w.scrollMaxY - w.scrollY) < THRESHOLD) {
lastMaxScrollY = w.scrollMaxY;
appending = true;
var anchor = Ten.Selector.getElementsBySelector('div.pager:first-child > a:first-child')[0];
var mEv = e = w.document.createEvent('MouseEvents');
mEv.initEvent('click',true,true);
anchor.dispatchEvent(mEv);
}
}
}, false);
w.addEventListener('dblclick', function(ev) {
enable = !enable;
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment