Skip to content

Instantly share code, notes, and snippets.

@vzvu3k6k
Created April 25, 2014 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vzvu3k6k/11295076 to your computer and use it in GitHub Desktop.
Save vzvu3k6k/11295076 to your computer and use it in GitHub Desktop.
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