Skip to content

Instantly share code, notes, and snippets.

@Minipada
Last active October 12, 2021 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Minipada/094b3ee68dbbc6eafbc237b542434c1b to your computer and use it in GitHub Desktop.
Save Minipada/094b3ee68dbbc6eafbc237b542434c1b to your computer and use it in GitHub Desktop.
delete stuff on facebook by simulating clicks. Not perfect, but can be done in less than 2 hours,
#!/bin/bash
set -e
# Arguments parsing
help() {
usage="$(basename "$0") --activity=<ACTIVITY> [ --comm-x-dots=<COMM_X_DOTS> --comm-y-dots=<COMM_Y_DOTS> --comm-x-del=<COMM_Y_DEL> --comm-y-del=<COMM_Y_DEL> ]
Delete Facebook information from the UI
Arguments:
--help/-h Show this help text
--activity Activity to delete: comments or posts (mandatory)
--window Window where facebook is loaded (mandatory)
--comm-x-dots X position on the screen for the ... button in comments Facebook (optional)
--comm-y-dots Y position on the screen for the ... button in comments Facebook (optional)
--comm-x-del X position on the screen for the delete button in comments Facebook (optional)
--comm-y-del Y position on the screen for the delete button in comments Facebook (optional)
--post-x-dots X position on the screen for the ... button in posts Facebook (optional)
--post-y-dots Y position on the screen for the ... button in posts Facebook (optional)
--post-x-del X position on the screen for the delete button in posts Facebook (optional)
--post-y-del Y position on the screen for the delete button in posts Facebook (optional)
--post-x-confirm X position on the screen for the confirm button in posts Facebook (optional)
--post-y-confirm Y position on the screen for the confirm button in posts Facebook (optional)
"
echo "${usage}"
}
if [ "$#" -lt 1 ]; then
help
exit 1
fi
for i in "$@"
do
case $i in
--activity=*)
ACTIVITY="${i#*=}"
shift # past argument=value
;;
--window=*)
WINDOW="${i#*=}"
shift # past argument=value
;;
--comm-x-dots=*)
COMM_X_DOTS="${i#*=}"
shift # past argument=value
;;
--comm-y-dots=*)
COMM_Y_DOTS="${i#*=}"
shift # past argument=value
;;
--comm-x-del=*)
COMM_X_DEL="${i#*=}"
shift # past argument=value
;;
--comm-y-del=*)
COMM_Y_DEL="${i#*=}"
shift # past argument=value
;;
--post-x-dots=*)
POST_X_DOTS="${i#*=}"
shift # past argument=value
;;
--post-y-dots=*)
POST_Y_DOTS="${i#*=}"
shift # past argument=value
;;
--post-x-del=*)
POST_X_DEL="${i#*=}"
shift # past argument=value
;;
--post-y-del=*)
POST_Y_DEL="${i#*=}"
shift # past argument=value
;;
--post-x-confirm=*)
POST_X_CONFIRM="${i#*=}"
shift # past argument=value
;;
--post-y-confirm=*)
POST_Y_CONFIRM="${i#*=}"
shift # past argument=value
;;
--help)
HELP=YES
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
# Arguments check
if [ -n "${HELP}" ]; then
help
exit 0
fi
if [ -z "${WINDOW}" ] || [ -z "${ACTIVITY}" ]; then
echo "123"
exit 0
fi
if [ "${ACTIVITY}" == "comments" ]; then
if [ -n "${COMM_X_DOTS}" ] && [ -n "${COMM_Y_DOTS}" ] && [ -n "${COMM_X_DEL}" ] && [ -n "${COMM_Y_DEL}" ]; then
while true; do
# Click on the 3 dots
xdotool mousemove ${COMM_X_DOTS} ${COMM_Y_DOTS}
xdotool click --window ${WINDOW} --delay 12 1
# Click on delete
xdotool mousemove ${COMM_X_DEL} ${COMM_Y_DEL}
xdotool click --window ${WINDOW} --delay 50 1
done
else
echo "Please setup all variables (dots, button)"
exit 1
fi
elif [ "${ACTIVITY}" == "posts" ]; then
if [ -n "${POST_X_DOTS}" ] && [ -n "${POST_Y_DOTS}" ] && [ -n "${POST_X_DEL}" ] && [ -n "${POST_Y_DEL}" ] && [ -n "${POST_X_CONFIRM}" ] && [ -n "${POST_Y_CONFIRM}" ]; then
while true; do
# Click on the 3 dots
xdotool mousemove ${POST_X_DOTS} ${POST_Y_DOTS}
xdotool click --window ${WINDOW} --delay 50 1
# Click on delete
xdotool mousemove ${POST_X_DEL} ${POST_Y_DEL}
xdotool click --window ${WINDOW} --delay 100 1
# Click on confirm delete
xdotool mousemove ${POST_X_CONFIRM} ${POST_Y_CONFIRM}
xdotool click --window ${WINDOW} --delay 150 1
sleep 0.1
done
else
echo "Please setup all variables (dots, button, confirm)"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment