
Tumblr Queueの最新ページへのリンクを生成するGreasemonkeyを更新しました。
インストール
https://gist.github.com/raw/614547/tumblr_queue_latest_link.user.js変更点
QueueのURL変更に対応しました。更新履歴
0.2.1 -> 0.2.2 (2011/10/29)
- QueueのURL変更に対応しました
0.2.0 -> 0.2.1 (2011/09/06)
- ダッシュボードのデザイン変更に対応しました
0.1.1 -> 0.2.0 (2011/06/12)
- syoichiさんのコードを受け入れ
ソース
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 | |
// @namespace http://nplll.com/greasemonkeys | |
// @description Tumblr Queueの最新ページへのリンクを生成するGreasemonkey | |
// @version 1.1.2 | |
// @downloadURL https://gist.github.com/raw/614547/tumblr_queue_latest_link.user.js | |
// @updateURL https://gist.github.com/raw/614547/tumblr_queue_latest_link.user.js | |
// @include http://www.tumblr.com/blog/* | |
// @include https://www.tumblr.com/blog/* | |
// @include http://www.tumblr.com/dashboard* | |
// @include https://www.tumblr.com/dashboard* | |
// @grant none | |
// @author Ippei "is" Suzuki | |
// @license MIT License; http://en.wikipedia.org/wiki/MIT_License | |
// ==/UserScript== | |
// Version History: | |
// 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デザイン変更に対応 | |
// 1.0.0 - 2012/10/18 コード整形とMetadataの変更、バージョンを1.0.0に | |
// 1.0.1 - 2014/02/25 https対応 | |
// 1.1.0 - 2014/03/08 前後のボタンを追加 | |
// 1.1.1 - 2014/03/08 bugfix | |
// 1.1.2 - 2015/01/02 レイアウト変更に対応 | |
(function(doc) { | |
var $ = function(name) { | |
return doc.querySelector(name); | |
} | |
var getButton = function(id, url) { | |
var b = document.createElement('a'); | |
b.setAttribute('id', id + 'Button'); | |
b.style.display = 'inner-block'; | |
b.style.position = 'fixed'; | |
b.style.backgroundColor = '#37506A'; | |
b.style.padding = '20px'; | |
b.style.fontFamily = 'Helvetica Neue'; | |
b.style.fontSize = '14px'; | |
b.style.fontWeight = 'bold'; | |
b.style.borderRadius = '10px'; | |
b.setAttribute('href', url); | |
b.style.color = 'white'; | |
b.textContent = id; | |
return b; | |
}; | |
var node = $('.queue .count'), latest = node && Math.ceil(Number(node.textContent) / 10) - 1, range, parent, latestUrl, current, prev, next, prevUrl, nextUrl, prevButton, nextButton, prevLink, nextLink, content = $('#left_column'); | |
if(!latest) { | |
return; | |
} | |
latest += 1; | |
//current | |
if(location.search){ | |
current = parseInt(location.search.substr(1).split('&')[0].split('=')[1]); | |
} else if(location.pathname.match(/queue$/)) { | |
current = 1; | |
} | |
//prev | |
if(current > 1) { | |
prev = current - 1; | |
} | |
//next | |
if(current < latest) { | |
next = current + 1; | |
} | |
//show latest | |
range = doc.createRange(); | |
parent = $('.controls_section .queue').parentNode; | |
latestUrl = parent.querySelector('a').href + '?page=' + String(latest); | |
range.selectNodeContents(doc.body); | |
parent.parentNode.insertBefore(range.createContextualFragment('<li' + (latestUrl === location.href ? ' class="selected"' : '') + '>' | |
+ '<a href="' + latestUrl + '" class="control-item control-anchor queue" style="padding-left: 40px">Latest</a>' + '</li>'), parent.nextSibling); | |
//show prev | |
if(typeof prev !== 'undefined') { | |
prevUrl = parent.querySelector('a').href + '?page=' + String(prev); | |
prevButton = getButton('prev', prevUrl); | |
prevButton.style.top = (window.innerHeight / 2 - 30) + 'px'; | |
prevButton.style.left = ((window.innerWidth - content.parentNode.offsetWidth) / 2 - 87) + 'px'; | |
content.parentNode.insertBefore(prevButton, content); | |
} | |
//show next | |
if(typeof next !== 'undefined') { | |
nextUrl = parent.querySelector('a').href + '?page=' + String(next); | |
nextButton = getButton('next', nextUrl); | |
nextButton.style.top = (window.innerHeight / 2 - 30) + 'px'; | |
nextButton.style.left = ((window.innerWidth + content.parentNode.offsetWidth) / 2 + 20) + 'px'; | |
content.parentNode.insertBefore(nextButton, content); | |
} | |
}(document)); |