Created
August 4, 2011 04:32
-
-
Save nkmrgk/1124515 to your computer and use it in GitHub Desktop.
Load next notes on tumblr
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 Show more notes | |
// @namespace http://nkmrgk.tumblr.com/ | |
// @description Load next notes on tumblr | |
// @include http://*.tumblr.com/post/* | |
// ==/UserScript== | |
(function() { | |
var is_in_view = function(elem) { | |
// ref: http://d.hatena.ne.jp/edvakf/20100205/1265338487 | |
var rect = elem.getBoundingClientRect(); | |
if (rect.left < 0 || rect.left > window.innerWidth || | |
rect.top < 0 || rect.top > window.innerHeight) { | |
return false; | |
} | |
return elem === document.elementFromPoint(rect.left, rect.top); | |
}; | |
window.addEventListener('scroll', function() { | |
var button = document.querySelector('.more_notes_link'); | |
if (is_in_view(button)) { | |
var event = document.createEvent('MouseEvents'); | |
event.initMouseEvent('click',true,true,window,0,0,0,0,0,false,false,false,false,0,null); | |
button.dispatchEvent(event); | |
} | |
}, false); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment