Created
July 23, 2008 23:37
-
-
Save hotchpotch/1943 to your computer and use it in GitHub Desktop.
Autopagerize for haiku
This file contains hidden or 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 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); |
This file contains hidden or 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
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment