// ==UserScript==
// @name Blogger keep current time on post
// @namespace http://browservulsel.blogspot.com/
// @description v0.3.1+ - Blogger keep current time on post
// @include http://*blogger.com/post-*
// @include http://*blogger.com/posts.g?blogID=*
// ==/UserScript==
/*
Author: Jasper de Vries, jepsar@gmail.com
Date: 2005-12-20
*/
if (self.location.pathname.match(/posts.g/)) {
var result = document.evaluate(
'//table[@id="posts"]//span[@class="draft"]/../..//a[contains(@href, "/post-edit.g?")]',
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null
);
for (var i = 0; i < result.snapshotLength; i++) result.snapshotItem(i).href += '&draft=1';
}
else {
var node, keepCurrentTO;
function keepCurrentClick(e) {
if (e.originalTarget.checked) keepCurrentTime();
else clearTimeout(keepCurrentTO);
}
function keepCurrentTime() {
var now = new Date();
var selects = postDate.getElementsByTagName('select');
selects[0].selectedIndex = (now.getHours() + 11) % 12;
selects[1].selectedIndex = now.getMinutes();
selects[2].selectedIndex = Math.floor(now.getHours() / 12);
selects[3].selectedIndex = now.getMonth();
selects[4].selectedIndex = now.getDate() - 1;
selects[5].selectedIndex = selects[5].length - 1 - (selects[5][selects[5].length - 1].text - now.getFullYear());
keepCurrentTO = setTimeout(keepCurrentTime, 100);
}
var postDate = document.getElementById('postDate');
if (postDate) {
var autoDate = document.createElement('label');
checkbox = document.createElement('input');
checkbox.setAttribute('type', 'checkbox');
if (
self.location.search.match(/draft=1/) || (
!document.getElementById('stuffform').elements.namedItem('postID') &&
!self.location.search.match(/quickEdit=true/)
)
) {
checkbox.setAttribute('checked', 'checked');
keepCurrentTime();
}
checkbox.addEventListener('click', keepCurrentClick, false);
autoDate.appendChild(checkbox);
autoDate.appendChild(document.createTextNode('Keep current time'));
postDate.insertBefore(autoDate, postDate.childNodes[5]);
}
unsafeWindow.setInterval(function(){
document.getElementById('togglePostOptions').style.display = 'none';
document.getElementById('postoptions').style.display = 'block';
}, 50);
}