Created
October 7, 2013 07:21
-
-
Save poochin/6863766 to your computer and use it in GitHub Desktop.
dashboard で次ページ読み込み時にページリンクを挿入します
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 Page Link on Dashboard | |
// @namespace https://github.com/poochin | |
// @include http://www.tumblr.com/dashboard* | |
// @include http://www.tumblr.com/show* | |
// @include http://www.tumblr.com/tagged* | |
// @version 1.0.0 | |
// @description ダッシュボードで次ページの読み込み時にページリンクを挿入させます | |
// | |
// @author poochin | |
// @license MIT | |
// @updated 2012-06-16 | |
// @updateURL https://github.com/poochin/tumblrscript/raw/master/userscript/dashboad_loadian.user.js | |
// ==/UserScript== | |
(function PageLinkOnDashboard() { | |
'use strict'; | |
boot(); | |
function appendPageLink(){ | |
var li = document.createElement('li'), | |
page_info = document.createElement('div'); | |
li.setAttribute('style', 'margin: 5px'); | |
li.appendChild(document.createElement('hr')); | |
li.appendChild(page_info); | |
page_info.innerHTML = ['<a style="color: white;" href="', next_page ,'">Page Link</a>'].join(''); | |
posts.appendChild(li) | |
} | |
function main() { | |
var script = document.createElement('script'); | |
script.innerHTML = [ | |
appendPageLink, | |
'BeforeAutoPaginationQueue.push(appendPageLink);', | |
].join('\n'); | |
console.log(true); | |
document.body.appendChild(script); | |
} | |
/** | |
* 実行すべきページかどうかを判断します。 | |
* Opera 用のコードです。 | |
* @return {Bool} 実行すべきページなら true を返します | |
*/ | |
function isExecPage() { | |
return /^https?:\/\/www\.tumblr\.com\/dashboard.*/.test(location) || | |
/^https?:\/\/www\.tumblr\.com\/show.*/.test(location) || | |
/^https?:\/\/www\.tumblr\.com\/tagged.*/.test(location); | |
} | |
/** | |
* 始めに呼び出される関数です。 | |
* 実行すべきページの場合は main 関数を呼びだすようにします。 | |
*/ | |
function boot() { | |
if (isExecPage() === false) { | |
return; | |
} | |
if (window.document.body) { | |
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