Comment by capableweb

3 years ago

By using `localStorage.my_comments`, here is another addon-script that formats the top/worst list for HN and puts the output into your clipboard:

    const comments = JSON.parse(window.localStorage.getItem('my_comments'))

    let text = 'My top 3 comments:\n\n'
    comments.slice(0, 3).forEach((comment) => {
        text = text + `- ${comment.score} - ${comment.link} - ${comment.timestamp} - Story: ${comment.onstory} - Comment: ${JSON.stringify(comment.intro)}\n\n`
    })
    text = text + 'My 3 worst comments:\n\n'
    comments.slice(-3).forEach((comment) => {
        text = text + `- ${comment.score} - ${comment.link} - ${comment.timestamp} - Story: ${comment.onstory} - Comment: ${JSON.stringify(comment.intro)}\n\n`
    })
    copy(text)

Please note that you need to run the script from the submission before you can run the above script.

Example output:

My top 3 comments:

- 180 - https://news.ycombinator.com/item?id=35153482 - 2023-03-14T15:49:54 - Story: null - Comment: "Ah, it seems you're one of many who confuses \"crypto\" with cryptography and cryptocurrency. Cryptogr"