-
Notifications
You must be signed in to change notification settings - Fork 6
/
unpopular-posts-only.user.js
59 lines (47 loc) · 1.85 KB
/
unpopular-posts-only.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name unpopular-posts-only
// @namespace all-hail.lord-enki.net
// @description Remove posts from dash if they have too many notes
// @include https://www.tumblr.com/dashboard
// @version 1
// @grant none
// ==/UserScript==
function remove_popular_posts(){
console.log("Starting up unpopular-posts-only...\n")
notes_to_remove=[]
note_counts=document.getElementsByClassName("note_link_current")
console.log("Checking the number of notes for "+String(note_counts.length)+" posts.\n")
for (i=0; i<note_counts.length; i++) {
note=note_counts.item(i)
c=parseInt(note.getAttribute("data-count"))
if(c>1000) {
console.log("Post to remove has "+String(c)+" notes.\n")
notes_to_remove.push(note)
}
}
console.log("Removing "+String(notes_to_remove.length)+" posts.\n")
for (i=0; i<notes_to_remove.length; i++) {
note=notes_to_remove[i]
// post_container -> post_full -> post_wrapper -> post_footer -> post_notes -> post_notes_inner -> post_notes_label -> note_link_current
post_notes_label=note.parentElement
post_notes_inner=post_notes_label.parentElement
post_notes=post_notes_inner.parentElement
post_footer=post_notes.parentElement
post_wrapper=post_footer.parentElement
post_full=post_wrapper.parentElement
post_container=post_full.parentElement
//post_container.style.visibility="hidden";
//post_container.style.maxHeight=0;
post_full.style.opacity=0.25
console.log("Removed post\n")
}
console.log("Done removing posts")
}
remove_popular_posts()
// From: https://stackoverflow.com/questions/28194122/how-to-execute-a-greasemonkey-script-on-every-infinite-scrolling-event-in-a-twit
window.addEventListener('load', function() {
console.log("Load event triggered")
remove_popular_posts()
},
false);
console.log("Got here")