diff --git a/README.md b/README.md index aa9e64a..b6eaa6b 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,24 @@ requirements.txt`, then you can just run `python -m deletefb.deletefb.py` in the * It is recommended that you disable Two-Factor Authentication tempoprarily while you are running the script, in order to get the best experience. +* If you run into issues with Facebook complaining about your browser, + currently the only workaround is to manually click through them. + * If you do have 2-Factor Auth configured then the script will pause for 20 seconds to allow you to enter your code and log in. * You may also pass in a code by using the `-F` argument, e.g. `-F 111111`. +## Delete by year +* The tool supports passing the `--year` flag in order to delete wall posts by + year. It is incompatible with any mode other than `wall`. + +## Archival +* The tool will archive everything being deleted by default in `.log` files. + Currently they are simply stored as JSON objects for each line in the log. It + will archive the content, and a timestamp if it is available. You may disable + this feature by using `--no-archive`. + ## Headless mode * The tool supports running Chrome in headless mode with the `--headless` option, which may be preferable if you plan on running it in the background. diff --git a/deletefb/deletefb.py b/deletefb/deletefb.py index 0e91240..23e275d 100755 --- a/deletefb/deletefb.py +++ b/deletefb/deletefb.py @@ -4,6 +4,7 @@ import argparse import getpass from sys import exit +from os import environ from .tools.login import login from .tools.wall import delete_posts from .tools.likes import unlike_pages @@ -67,6 +68,14 @@ def run_delete(): help="Run browser in headless mode (no gui)" ) + parser.add_argument( + "--no-archive", + action="store_true", + dest="archive_off", + default=True, + help="Turn off archiving (on by default)" + ) + parser.add_argument( "-Y", "--year", @@ -78,6 +87,9 @@ def run_delete(): args = parser.parse_args() + if args.archive_off: + environ["DELETEFB_ARCHIVE"] = "false" if args.archive_off else "true" + if args.year and args.mode != "wall": parser.error("The --year option is only supported in wall mode") diff --git a/deletefb/tools/common.py b/deletefb/tools/common.py index 4b95ea1..9dc9e38 100644 --- a/deletefb/tools/common.py +++ b/deletefb/tools/common.py @@ -4,6 +4,7 @@ from selenium.common.exceptions import (NoSuchElementException, from time import sleep from json import dumps from os.path import abspath, relpath, split +from os import environ SELENIUM_EXCEPTIONS = (NoSuchElementException, StaleElementReferenceException, @@ -30,6 +31,8 @@ def archiver(category): log_file = open(log_path, mode="wt", buffering=1) def log(content, timestamp=False): + if environ.get("DELETEFB_ARCHIVE", "true") == "false": + return structured_content = { "category" : category, "content" : content,