Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syoichi/1791077 to your computer and use it in GitHub Desktop.
Save syoichi/1791077 to your computer and use it in GitHub Desktop.
AutoPatchWorkやendless scrollingを利用している時にも、読み込んだ次のページでポストの投稿時間が表示されるように修正した。また、Likeなどのページでも動作するように変更した。
// ==UserScript==
// @id Tumblr Dashboard Show Post Time
// @name Tumblr Dashboard Show Post Time
// @namespace http://saitamanodoruji.tumblr.com/
// @author saitamanodoruji
// @version 0.0.2
// @update 2012-02-11T02:31:23.029Z(GMT+09:00)
// @description TumblrのDashboardなどのページでポストの横に投稿時間を表示する。
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/likes*
// @include http://www.tumblr.com/liked/by/*
// @include http://www.tumblr.com/tagged/*
// @include http://www.tumblr.com/blog/*
// @exclude http://www.tumblr.com/dashboard/iframe*
// @exclude http://www.tumblr.com/blog/*/new/*
// @exclude http://www.tumblr.com/blog/*/reblog/*
// @run-at document-end
// @priority 0
// @compatibility Firefox 10.0(Scriptish 0.1.7, AutoPagerize 0.9.5), Chrome 17.0.963.46(AutoPagerize 0.3.4, AutoPatchWork 1.9.5), Safari 5.1.2(NinjaKit 0.8.5, AutoPagerize 0.3.3), Opera 11.61(AutoPatchWork 1.8.6) on Windows 7 Home Premium SP1 64bit
// @charset UTF-8
// ==/UserScript==
/*jslint browser: true, maxerr: 50, maxlen: 80, indent: 4*/
// Edition 2012-02-03
(function executeShowPostTime(doc) {
'use strict';
var avatarAndIs, avatarAndIsLen, permalinks, permalinksLen, showPostTime,
showPostTimeforNextPage;
avatarAndIs = doc.querySelectorAll('[id^="post_"] > .avatar_and_i');
avatarAndIsLen = avatarAndIs.length;
permalinks = doc.querySelectorAll('.permalink');
permalinksLen = permalinks.length;
if (
!(avatarAndIsLen && permalinksLen && avatarAndIsLen === permalinksLen)
) {
return;
}
doc.head.appendChild(doc.createElement('style')).textContent = [
'.posttime {',
' width: 64px !important;',
' position: absolute !important;',
' top: 70px !important;',
' left: -85px !important;',
' margin-top: 5px !important;',
' text-align: center !important;',
' color: #95A6BD !important;',
'}',
'.same_user_as_last .posttime {',
' top: 0 !important;',
' margin-top: 0 !important;',
'}'
].join('\n');
showPostTime = function showPostTime(avatarAndI, permalink) {
avatarAndI.insertAdjacentHTML(
'AfterEnd',
'<div class="posttime">' +
permalink.title
.replace(/^View post - |,/g, '')
.replace(/^([A-Z][a-z]{2})[a-z]+/, '$1') +
'</div>'
);
};
while (permalinksLen) {
showPostTime(
avatarAndIs[permalinksLen -= 1],
permalinks[permalinksLen]
);
}
showPostTimeforNextPage = function showPostTimeforNextPage(evt) {
var target, avatarAndI, permalink;
target = evt.target;
if (!/^post_/.test(target.id)) {
return;
}
avatarAndI = target.querySelector('.avatar_and_i');
permalink = target.querySelector('.permalink');
if (!(avatarAndI && permalink)) {
return;
}
showPostTime(avatarAndI, permalink);
};
doc.addEventListener('DOMNodeInserted', showPostTimeforNextPage);
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment