Forked from nobodyplace/tumblr_queue_latest_link.user.js
Created
June 11, 2011 17:13
-
-
Save syoichi/1020760 to your computer and use it in GitHub Desktop.
insertAdjacentHTMLを使うようにした。Mozilla Firefox 15.0.1(Scriptish 0.1.7)、Chrome 21.0.1180.89で動作を確認した。
This file contains 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 Tumblr Queue Latest Link Maker | |
// @version 0.2.4 | |
// @namespace http://nplll.com | |
// @description Tumblr Queueの最新ページへのリンクを生成するGreasemonkey | |
// @include http://www.tumblr.com/blog/* | |
// @include http://www.tumblr.com/dashboard* | |
// ==/UserScript== | |
// 0.0.1 - 2010/10/07 リリース | |
// 0.0.2 - 2010/11/07 二重表示防止 | |
// 0.1.0 - 2011/06/11 Dashboardリニューアルに対応 | |
// 0.1.1 - 2011/06/11 二重表示防止ID付け忘れ | |
// 0.2.0 - 2011/06/12 syoichiさんのforkをmerge thanks:) | |
// + 動作の対象をTumblelogのみに(syoichi) | |
// + Messagesの有効時に対応(syoichi) | |
// + Queueを使用していないときにエラーが出ないように修正(syoichi) | |
// + selected時の効果をQueueの最新ページを閲覧している時に限定(syoichi) | |
// 0.2.1 - 2011/09/06 Dashboardデザイン変更に対応 | |
// 0.2.2 - 2011/10/29 QueueページのURL変更に対応 | |
// 0.2.3 - 2012/09/08 Dashboardデザイン変更に対応 | |
/*jslint browser: true, maxlen: 80, indent: 2*/ | |
// Edition 2012-09-18 | |
(function executeAddQueueLatestLink(doc) { | |
'use strict'; | |
var queue, count, latestNumber, latestURL; | |
queue = doc.querySelector('.controls_section .queue'); | |
if (!queue) { | |
return; | |
} | |
count = queue.querySelector('.count'); | |
if (!count) { | |
return; | |
} | |
latestNumber = Math.ceil(count.textContent / 10); | |
if (latestNumber < 2) { | |
return; | |
} | |
latestURL = queue.href + '?page=' + latestNumber; | |
queue.parentNode.insertAdjacentHTML('AfterEnd', [ | |
'<li' + (latestURL === location.href ? ' class="selected"' : '') + '>', | |
' <a href="' + latestURL + '" class="queue">Latest</a>', | |
'</li>' | |
].join('')); | |
}(document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment