cross-posted from: https://lemmy.ca/post/1665374

This is a great tool to overwrite your posts with random words and a link to get others to consider doing so as well.

Once my comments are all gone, I’m gonna delete the posts too.

EDIT: …and I’m perma-banned :). Guess they don’t like mentioning lemmy.whynotdrs.org (“… attempting to pillage the community to start another”). Yeah, that’s kinda the point. Buh-bye rexxit.

    • Arghblarg@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 year ago

      I first overwrote them all with random words, then with an explanation of why (reddit API protest, and superstonk censorship, mentioning whynotdrs). Woke up this morning to find I’m perma-banned :). They don’t want users attempting to call attention to other communities:

      Hello, You have been permanently banned from participating in r/Superstonk because your comment violates this community’s rules. You won’t be able to post or comment, but you can still view and subscribe to it.

      Note from the moderators:

      You’ve chosen to attempt to pillage this community to build another. If there’s another community you’d rather be part of you’re welcome to go there instead.

      If you have a question regarding your ban, you can contact the moderator team by replying to this message.

      Reminder from the Reddit staff: If you use another account to circumvent this subreddit ban, that will be considered a violation of the Content Policy and can result in your account being suspended from the site as a whole.

  • dishwashingunit@lemmy.whynotdrs.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    If you don’t want to trust a third-party service, here’s some really ugly code that I spun up quite a while ago when I still sucked at coding (even though I still do), along with some instructions that I chatGPT’d for it. It doesn’t handle your posts, only comments. I never had enough posts to bother when I could just do it by hand.

    Still seems to work even with API restrictions, but maybe that’s because I didn’t hit the limit when I tested it out just now.

    
    import json
    import requests
    import keyring
    import essential_generators
    
    CLIENT_ID=keyring.get_password("Redacted", "CLIENT_ID")
    CLIENT_SECRET=keyring.get_password("Redacted", "CLIENT_SECRET")
    REFRESH_TOKEN=keyring.get_password("Redacted", "REFRESH_TOKEN")
    
    USER_AGENT="(redacted)"
    BASE_URL="https://oauth.reddit.com"
    DEFAULT_USERNAME = "(your user name)"
    
    auth = requests.auth.HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)
    headers = {"User-Agent": USER_AGENT}
    sentence_generator = essential_generators.DocumentGenerator()
    
    
    def _refresh_access_token():
    
        post_data = {"grant_type": "refresh_token", "refresh_token": REFRESH_TOKEN}
        response = requests.post("https://www.reddit.com/api/v1/access_token", auth=auth, data=post_data, headers=headers)
        return response.json()
    
    def who_am_i():
        return requests.get(BASE_URL + "/api/v1/me", headers=headers).json()
    
    def make_json_pretty(json_object: dict | str) -> json:
        return print(json.dumps(json_object, indent=4))
    
    def get_list_of_comments(username = DEFAULT_USERNAME):
        if username is None:
           username = who_am_i().get("name")
        return requests.get(BASE_URL + "/user/" + username + "/comments", headers=headers, params={"limit": 100}).json()
    
    def overwrite_a_comment(thing_id):
        random_sentence = sentence_generator.sentence()
        post_data = {"api_type": "json", "text": random_sentence, "thing_id": thing_id}
        requests.post(BASE_URL + "/api/editusertext", data=post_data, headers=headers).json()
        return random_sentence
    
    def delete_a_comment(thing_id):
        post_data = {"id": thing_id}
        return requests.post(BASE_URL + "/api/del", data=post_data, headers=headers)
    
    def parse_comment_batch(list_of_comments):
        results = []
        for comment in list_of_comments['data']['children']:
             results.append((comment['data']['id'], comment['data']['body']))
        return results
    
    def overwrite_and_delete_all_comments():
        while(True):
            batch_of_comments = parse_comment_batch(get_list_of_comments())
            if (not batch_of_comments):
                return
            for thing_id, comment in batch_of_comments:
                if (not thing_id):
                    break
                print("Overwriting " + thing_id + " " + comment + " with " + overwrite_a_comment("t1_" + thing_id))
                print("Deleting " + thing_id)
                delete_a_comment("t1_" + thing_id)
    
                
    
    if __name__ == "__main__":
        TOKEN = _refresh_access_token()['access_token']
        headers['Authorization'] = f'bearer {TOKEN}'
        
        overwrite_and_delete_all_comments()
        
    

    Sure, here are the steps you need to follow to use this script to overwrite and delete all comments from your Reddit account:

    1. Prerequisites

      This script requires Python and the following Python packages: requests, keyring, and essential_generators. You can install them using pip:

      pip install requests keyring essential_generators
      
    2. Obtain your Reddit App’s Client ID and Secret

      You need a Reddit app’s client ID and secret to use Reddit’s API. To obtain these, follow these steps:

      • Log into Reddit on your web browser.
      • Go to the App preferences page.
      • Scroll down to the “Developed Applications” section and click “Create App” or “Create Another App”.
      • Fill out the form:
        • name: Any name will do.
        • App type: Choose “script”.
        • description: Can be left blank.
        • about url: Can be left blank.
        • redirect uri: http://localhost:8080
        • permissions: Choose ‘read’.
      • Click “Create app”.
      • On the app details page, you will see a section named “Developed Applications”. Here, the client ID is listed under the web app you just created, just below the web app title. It is a string of characters and numbers. The client secret is listed as “secret”.
    3. Save Your Client ID, Secret, and Refresh Token in Your Keyring

      Use Python’s keyring package to securely save your Reddit app’s client ID, client secret, and Reddit account’s refresh token. You can use the following Python commands to store these values:

      import keyring
      
      keyring.set_password("YourServiceName", "CLIENT_ID", "YourClientID")
      keyring.set_password("YourServiceName", "CLIENT_SECRET", "YourClientSecret")
      keyring.set_password("YourServiceName", "REFRESH_TOKEN", "YourRefreshToken")
      

      Replace "YourServiceName", "YourClientID", "YourClientSecret", and "YourRefreshToken" with the actual service name, client ID, client secret, and refresh token. The service name can be any name you choose—it’s just an identifier for you to use.

    4. Update the Service Name and Username in the Python Script

      Replace "Redacted" in the following lines of the Python script with your service name:

      CLIENT_ID=keyring.get_password("YourServiceName", "CLIENT_ID")
      CLIENT_SECRET=keyring.get_password("YourServiceName", "CLIENT_SECRET")
      REFRESH_TOKEN=keyring.get_password("YourServiceName", "REFRESH_TOKEN")
      

      Replace "(your user name)" in the following line with your Reddit username:

      DEFAULT_USERNAME = "(your user name)"
      
    5. Run the Python Script

      After setting up everything, run the Python script. It will fetch all your Reddit comments and overwrite them with random sentences, then delete them.

    Please remember, use this script responsibly. It will delete all of your Reddit comments, and the process is irreversible. Always double-check the script and make sure you’re ready to delete all comments before running it.

    • Arghblarg@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Nice. If you don’t want to get banned, I’d suggest putting in a long, random sleep right after the call to delete_a_comment() and letting it run over days rather than trying to do them all at once. Unless you want to make a point, I suppose :p

  • DoctorPlasmatron@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    One caution I would have about removing all the reddit backstory is that if someone uninformed goes to look into things they’re going to start with reddit since that’s where it all began, and without some record of fuckery, investigations, and findings they will only see what the compromised redditors want them to see (ie. it’s all over, you missed it, etc.)

    Does the app you’re pointing folks to make it easy to selectively keep some of the comments or would it be a laborious message-by-message deletion if you wanted to just remove things with identifying details, etc.?

    • Arghblarg@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Yeah, I thought about that too. The tool allows selecting which posts/comments to update or delete via keyword and date filters I believe.

      I didn’t myself ever post any groundbreaking DD on SStonk, so I had no big reservations about nuking my own comments from there at least :p