Selenium script to delete all submissions and comments on voat.co

1    27 Nov 2018 20:01 by u/aGameCalledCountries

Below is a script to delete all of your submissions and comments on voat. Change the USERNAME and PASS in the script and run.

To install selenium on mac, pip install selenium and brew cask install chromedriver.

#!/usr/bin/env python3
"""
Module for deleting all submissions and comments on voat.co
"""
#import sys
import time
from selenium import webdriver
USERNAME = ""
PASS = ""
def login(d):
    body = d.find_element_by_tag_name("body")
    body.click()
    c1 = d.find_element_by_id("container")
    c = c1.find_element_by_id("loginForm")
    for l in c.find_elements_by_tag_name("label"):
        try:
            l.click()
        except:
            pass
    c.find_element_by_id("UserName").send_keys(USERNAME)
    c.find_element_by_id("Password").send_keys(PASS)
    for btn in c.find_elements_by_tag_name("input"):
        if btn.get_attribute("value") == "Log in":
            btn.click()
            break
    time.sleep(1)
def delete_submissions(d):
    cw = driver.current_window_handle
    while True:
        c = d.find_element_by_id("container")
        for comments in c.find_elements_by_class_name("comments"):
            href = comments.get_attribute("href")
            print(href)
            d.execute_script("window.open('about:blank', 'link');")
            d.switch_to.window("link")
            d.get(href)
            time.sleep(1)
            ent = d.find_element_by_class_name("entry")
            ent.find_element_by_link_text("delete").click()
            ent.find_element_by_link_text("yes").click()
            time.sleep(1)
            d.close()
            d.switch_to.window(cw)
        try:
            c = d.find_element_by_id("container")
            nxt = c.find_element_by_link_text("next ›")
            nxt.click()
        except:
            break
def delete_comments(d):
    cw = driver.current_window_handle
    while True:
        c = d.find_element_by_id("container")
        for comments in c.find_elements_by_link_text("permalink"):
            href = comments.get_attribute("href")
            print(href)
            d.execute_script("window.open('about:blank', 'link');")
            d.switch_to.window("link")
            d.get(href)
            time.sleep(1)
            cmnt_area = d.find_element_by_class_name("commentarea")
            ent = cmnt_area.find_element_by_class_name("entry")
            ent.find_element_by_link_text("...").click()
            ent.find_element_by_link_text("delete").click()
            ent.find_element_by_link_text("yes").click()
            time.sleep(1)
            d.close()
            d.switch_to.window(cw)
        try:
            c = d.find_element_by_id("container")
            nxt = c.find_element_by_link_text("next ›")
            nxt.click()
        except:
            break
if __name__ == "__main__":
    # driver = sys.argv[1].strip().capitalize()
    # page = sys.argv[2].strip()
    page = "https://voat.co/account/login"
    driver_name = "Chrome"
    driver = getattr(webdriver, driver_name)()
    try:
        driver.set_page_load_timeout(10)
        driver.get(page)
        login(driver)
        page = "https://voat.co/u/%s/submissions" % USERNAME
        driver.get(page)
        delete_submissions(driver)
        page = "https://voat.co/u/%s/comments" % USERNAME
        driver.get(page)
        delete_comments(driver)
        time.sleep(3)
    finally:
        driver.close()

3 comments

0

Thanks. With deleting your account being broken if you're banned from a sub (did this ever get fixed?) this is a nice alternative.

0

My thoughts exactly.

0

This submission was linked from this v/AskVoat comment by @talmoridor-x.

Posted automatically (#15876) by the SearchVoat.co Cross-Link Bot. You can suppress these notifications by appending a forward-slash(/) to your Voat link. More information here.