Skip to content

Instantly share code, notes, and snippets.

@poochin
Created June 14, 2012 15:55
Show Gist options
  • Select an option

  • Save poochin/2931134 to your computer and use it in GitHub Desktop.

Select an option

Save poochin/2931134 to your computer and use it in GitHub Desktop.
Tumblr の dashboard で次ページ読み込み開始位置をずらします
// ==UserScript==
// @name Dashboard Loadian
// @match http://www.tumblr.com/dashboard*
// @version 1.0.1
// @description ダッシュボードの読み込み位置を前倒しします
//
// @author poochin
// @license MIT
// @updated 2012-06-15
// @updateURL https://gist.github.com/2931134
// ==/UserScript==
(function DashboardLoadian() {
/**
* クリックイベントです。
* Node.dispatch(left_click) として使います。
*/
var left_click = document.createEvent("MouseEvent");
left_click.initEvent("click", false, true);
/**
* クライアントエリアのスクロール位置、画面サイズを取得します
* @return {Object} left, top, width, height を備えた辞書を返します
*/
function viewportRect() {
return {
left: document.documentElement.scrollLeft || document.body.scrollLeft,
top: document.documentElement.scrollTop || document.body.scrollTop,
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight};
}
function onscroll() {
var vr = viewportRect();
if (document.documentElement.offsetHeight - (vr.top + vr.height) < 10000) {
var f = function() {
if (!loading_next_page) {
loading_next_page = true;
retry_auto_paginator_request();
}
};
location.assign('javascript: void ' + f + '()');
}
}
function main() {
window.addEventListener('scroll', onscroll, false);
}
function isExecPage() {
if (/^https?:\/\/www\.tumblr\.com\/dashboard.*/.test(location) /* for Opera */) {
return true;
}
}
if (window.document.body) {
if (isExecPage() /* for Opera */) {
main();
}
}
else {
window.document.addEventListener('DOMContentLoaded', main, false);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment