Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tumblr: Empty trails on dashboard
// ==UserScript==
// @name Tumblr: Empty trails on dashboard
// @description It won't work and you won't need it because of Tumblr.GhostList. /* Remove old posts on auto pagination. Similar to http://joodle.tumblr.com/post/14352059524/supertumblr, but works more efficiently. */
// @match http://www.tumblr.com/dashboard
// @match http://www.tumblr.com/dashboard/*
// @match https://www.tumblr.com/dashboard
// @match https://www.tumblr.com/dashboard/*
// @version 1.1
// @license public domain
// ==/UserScript==
location.href = "javascript:(" + function(){
function clearPosts(){
var maxNodes = 10;
var posts = document.querySelectorAll('#posts > .post_container:not(#new_post_buttons):not(._empty)');
Array.prototype.slice.call(posts, 0, posts.length - maxNodes).forEach(clearPost);
}
function clearPost(post){
post.classList.add('_empty');
var content = post.querySelector('.post');
content.style.height = post.getBoundingClientRect().height + 'px';
emptyNode(content);
}
function emptyNode(node){
while(node.firstChild) node.firstChild.remove();
}
Tumblr.AutoPaginator.on('after', clearPosts);
window.addEventListener('AutoPagerize_DOMNodeInserted', clearPosts);
window.addEventListener('AutoPatchWork.DOMNodeInserted', clearPosts);
} + ")()";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment