Now gets missing comments instead of crashing :)

This commit is contained in:
Jesper Wrang 2017-09-11 01:30:37 +02:00
parent 212b8c58da
commit a3e67d9557
2 changed files with 12 additions and 9 deletions

View file

@ -5,7 +5,7 @@ const htmlParser = new DOMParser();
const redditThreadURL = `https://oauth.reddit.com/r/${subreddit}/comments/${threadID}`
const redditMorechildrenURL = `https://oauth.reddit.com/api/morechildren?link_id=t3_${threadID}&children=`
const redditSingleCommentURL = `https://oauth.reddit.com/r/${subreddit}/api/info/?id=t1_`
const redditSingleCommentURL = `https://oauth.reddit.com/r/${subreddit}/api/info/?id=`
const pushshiftIDsURL = `https://api.pushshift.io/reddit/submission/comment_ids/${threadID}`
const pushshiftCommentsURL = "https://api.pushshift.io/reddit/comment/search?ids="
@ -67,7 +67,7 @@ async function loadPage() {
const removedComments = await getRemovedComments(allCommentIDs.data)
setLoadingText("Generating comments...")
generateComments(removedComments)
await generateComments(removedComments)
setLoadingText("")
loadingImage.src = doneImageSrc
@ -200,9 +200,6 @@ async function getCommentsToGenerate(commentsToLookup) {
newCommentsToLookup.push(parentID)
} else{
console.error("Comment doesn't exists, but lets try it anyway :D")
console.log("ID: " + id)
console.log("Parent: " + parent_id)
commentsToFetch.push(parentID)
}
@ -210,8 +207,14 @@ async function getCommentsToGenerate(commentsToLookup) {
})
if(commentsToFetch.length !== 0) {
//await
console.error("fuck it, ill fix it later")
const newComments = await fetch(redditSingleCommentURL + commentsToFetch.map(x => "t1_" + x).join(), redditInit).then(json)
console.log(newComments)
newComments.data.children.forEach(x => {
console.log(x.data.id)
commentLookup.set(x.data.id, x.data)
newCommentsToLookup.push(x.data.id)
})
}
if(newCommentsToLookup.length !== 0) {

View file

@ -6,8 +6,8 @@
<p>
<b>How to use</b>: go to any Reddit thread and replace the <i>reddit</i> in the URL with <i>removeddit</i>
<br>E.g.
<a href="/r/changelog/comments/6xfyfg/">
https://www.removeddit.com/r/changelog/comments/6xfyfg/
<a href="/r/TwoXChromosomes/comments/6z1hch/malala_says_oxford_was_the_hardest_interview_of/">
https://www.removeddit.com/r/TwoXChromosomes/comments/6z1hch/malala_says_oxford_was_the_hardest_interview_of/
</a>
</p>
<p>