summaryrefslogtreecommitdiff
path: root/cookiebanners/screen/y.sh
blob: 019193afb5b3212fa5b937af42ddbc8cb9dc6143 (plain)
  1. #!/bin/sh
  2. # break on error
  3. set -eu
  4. # top 1000 domains
  5. # * go to <https://dataforseo.com/free-seo-stats/top-1000-websites>
  6. # * select "Denmark"
  7. # * download
  8. json_file="ranked_domains.json"
  9. # count Firefox windows
  10. firefox_windows() {
  11. swaymsg -t get_tree | jq '[recurse(.nodes[]? | .nodes[]?)] | map(select(.app_id == "firefox-esr")) | length'
  12. }
  13. # count already opened Firefox windows
  14. baseline_windows=$(firefox_windows)
  15. # iterate through top domains and collect data about each
  16. jq -c '.[]' "$json_file" | while read -r item; do
  17. domain=$(echo "$item" | jq -r '.domain')
  18. pos=$(echo "$item" | jq -r '.position')
  19. # skip if screenshot already exist for this domain
  20. [ ! -e "$pos.png" ] || continue
  21. # load front page of www host at domain into Firefox
  22. firefox --new-window "https://www.$domain"
  23. # wait until firefox window is closed
  24. while true; do
  25. sleep 1
  26. if [ "$(firefox_windows)" -eq "$baseline_windows" ]; then
  27. break
  28. fi
  29. done
  30. # collect PNG screenshot
  31. # * use tool grimshot
  32. find ~/ -mindepth 1 -maxdepth 1 -name '*.png' -exec mv '{}' "$pos.png" ';'
  33. # collect HAR network timing data
  34. # * Open debugger window: F12
  35. # * Select pane "Network"
  36. # * From rightmost pane, select "Save all as HAR"
  37. find ~/data -mindepth 1 -maxdepth 1 -name '*.har' -exec mv '{}' "$pos.har" ';'
  38. # collect data: PNG screenshot, HAR network timing and PDF screenshot
  39. # * use plugin <https://addons.mozilla.org/da/firefox/addon/save-pdf/>
  40. find ~/data -mindepth 1 -maxdepth 1 -name '*' -exec mv '{}' "$pos.pdf" ';'
  41. done