Skip to content

Instantly share code, notes, and snippets.

@hugocf
Created April 2, 2024 18:23
Show Gist options
  • Save hugocf/1720f31de8beae4bd9170e1adf019679 to your computer and use it in GitHub Desktop.
Save hugocf/1720f31de8beae4bd9170e1adf019679 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Get mouse coordinates with: cliclick p
readonly catalogue=88,382
readonly kind=326,388
readonly kind_location=329,582
readonly first_location=505,478
readonly three_dots=1338,218
readonly unregister_entity=1273,271
readonly delete_entity=474,809
readonly cancel_delete=599,809
readonly window_focus=68,883
click() {
cliclick c:$1
wait 200
}
wait() {
local ms=$1
cliclick w:$ms
}
close_tab() {
cliclick kd:cmd
cliclick t:w
cliclick ku:cmd
}
refresh_tab() {
cliclick kd:cmd
cliclick t:r
cliclick ku:cmd
}
delete_location_cancel() {
click $first_location
click $three_dots
click $unregister_entity
click $cancel_delete
}
delete_location_confirm() {
click $first_location
click $three_dots
click $unregister_entity
click $delete_entity
}
list_locations() {
click $catalogue
click $kind
click $kind_location
}
# Brittle
# - More autonomous but only for smaller number of iterations
# - Breaks whenever a Location has dependencies that move the Delete button to another coordinate
delete_locations_opening_one_by_one() {
local iterations=$1
for _ in $(seq 1 $iterations); do
list_locations
wait 2500
delete_location_confirm
done
list_locations
}
# Faster
# - Pre-open hundreds of tabs with the Linkclump Chrome Extension
# - Resilient to misplaced Delete buttons by skipping over and closing its tab
delete_locations_in_opened_tabs() {
local iterations=$1
click $window_focus
for _ in $(seq 1 $iterations); do
delete_location_confirm
close_tab
wait 200
done
refresh_tab
}
how_many=${1:-1} # Defaults to only 1
# delete_locations_opening_one_by_one "$how_many"
delete_locations_in_opened_tabs "$how_many"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment