Script giving some info about STG. A dashboard of some sorts.

The output:

STG 110/2568 00:51:12
about:blank
https://c7.ee
http://localhost:1313

Indicating:

  • This is STG talking.
  • 110 tabs are not archived.
  • 2568 tabs total.
  • Last backup, and where this information was pulled from was made 0 hours, 51 minutes, 12 seconds ago.
  • 3 URLs appear duplicate. Paste the line to STG search, and you’l see.
    • about:newtab is not displayed here.
    • about:blank can mean tabrot (bitrot, but for tabs). This is usually happens when archiving a group after just opening the tab in there, and the tab was in the middle of an interaction with an another add-on of yours, for example containers.

Dependancies

  • jq
  • wc
  • uniq
  • bc
  • cut
  • rev
  • sort
  • grep
  • sed
  • date
  • tail
  • ls
  • bash (other shells will likely work, works on zsh)

Script

#!/bin/bash

backloc=~/Downloads/your-browser-profile-or-other-location-for-backups-to-get-data-from

file="$backloc"/"$(ls -Art "$backloc" | tail -n 1)"
datebase="$(rev <<< "$file" | cut -d@ -f 2 | cut -d- -f 1-4 | rev)" # rev implementation not needed anymore, retains compatability with different backup nameschemes.
stgepoch="$(date -d "$(echo "$(cut -d~ -f 1 <<< "$datebase")"T"$(cut -d~ -f 2 <<< "$datebase" | sed "s/-/:/")+00:00")" "+%s")"
epochdiff="$(echo "$(date "+%s")"-"$stgepoch" | bc)"

# header, nonarchived/total tabs, last backup relative time
echo "STG" "$(jq '.groups[] | select(.isArchive == false) | .tabs[].url' "$file" | wc -l)"/"$(jq '.groups[].tabs[].url' "$file" | wc -l)" "$(date -d@"$epochdiff" -u +%H:%M:%S)"
jq -r ".groups[].tabs[].url" "$file" | sort | grep -vFx "about:newtab"| uniq -d | sort # duped tabs