Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async ()=>{let id = 0, comments = [], t_id = 929679, nComments = 5; /* note that comments are fetched in sets of 4, so you'll get nComments * 4 back*/
- let reverse = true;
- let loadMore = true;
- for (let i = 0; i < nComments; i++) {
- await fetch(`https://www.freeriderhd.com/track_comments/load_more/${t_id}/${id}`, {method: 'POST'}).then(i=>i.json()).then(i=>{comments.push(...i.data.track_comments); loadMore = i.data.track_comments_load_more});
- id = comments[comments.length - 1].comment.id;
- if (!loadMore) break;
- }
- if (reverse) comments = comments.reverse();
- let formatted = comments.map(i=>`${i.user.d_name} (${i.comment.time}): ${i.comment.msg.replaceAll(/\<a href\=\".+?\"\>(.+?)\<\/a\>/g, '@$1')}`).join('\n'),
- parser = new DOMParser(),
- dom = parser.parseFromString(
- '<!doctype html><body>' + formatted,
- 'text/html'
- ),
- corrected = dom.body.textContent;
- console.log(corrected)})()
Advertisement
Add Comment
Please, Sign In to add comment