Friday, March 31, 2023

Coding Challenge #38 Show Reddit comments without pressing button

This script would be convenient in a plugin to show all comments for a post

 

 // for plugin: display whole reddit post & responses without site JS enabled
d = document.getElementsByTagName('div');
console.log("total DIVs: " + d.length);
var firstPost = null;
for(var xint = 0, len = d.length;xint < len;xint++){
if(d[xint].getAttribute('data-scroller-first') != null){
console.log('found one');
console.log(d[xint]);
firstPost = d[xint];
break;
}
}

firstPost.style.maxHeight = "100%";
firstPost.parentElement.style.maxHeight = "100%";
firstPost.parentElement.parentElement.style.maxHeight = "100%"; // show all posts
// but white fade will still be over bottom-most post

// remove ads under topic post
postRoot = firstPost.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
postRoot.removeChild(postRoot.children[2]);

//work thus far on expanding reddit no extra scripts
/*
top most part of post
.parentElement.children[2]
that is who we want to delete (ads, irrelevant misc stuff)
[0] is tabindex
[1] is post
[2] is ads below with videos that autoplay when scrolled to (ew!)
*/

No comments:

Post a Comment

Coding Challenge #54 C++ int to std::string (no stringstream or to_string())

Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...