Created
April 25, 2014 16:20
-
-
Save vzvu3k6k/11295076 to your computer and use it in GitHub Desktop.
Tumblr: Empty trails on dashboard
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: 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