From 7632c673fabb62047fc43e0607afc712ccf7575a Mon Sep 17 00:00:00 2001 From: "suzanne.soy" Date: Fri, 9 Oct 2020 05:26:02 +0100 Subject: [PATCH 1/2] more error handling and use nix to bring in the dependencies --- export-chrome-bookmarks.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/export-chrome-bookmarks.sh b/export-chrome-bookmarks.sh index 51df5df..fbae51e 100755 --- a/export-chrome-bookmarks.sh +++ b/export-chrome-bookmarks.sh @@ -1,3 +1,16 @@ -#!/bin/bash +#!/usr/bin/env nix-shell +#!nix-shell --pure -i bash -p dejsonlz4 jq bash -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/fea633695211167753ee732c9087808d0c57461c.tar.gz -jq '.roots[] | recurse(.children?[]?) | "\( .name? ): \( .url? )"' ~suzanne/apps/chromium/.config/chromium/Default/Bookmarks +# Usage: ./export-firefox-bookmarks.sh [path/to/.mozilla/firefox/XXXXXXXX.profile] + +set -euET -o pipefail + +if test $# -ge 1; then + profile="$1" +else + # use printf to avoid echo's ambiguity; save trailing whitespace with a dummy x (not needed here as the string ends with "Default", but a good habit nevertheless) + profile="$(printf "%sx" ~/.config/chromium/Default/)" + profile="${profile%x}" +fi + +jq '.roots[] | recurse(.children?[]?) | "\( .name? ): \( .url? )"' < "$profile"/Bookmarks From 1b3c5871a282b7377d04a456ea08a9d6eca5df2c Mon Sep 17 00:00:00 2001 From: "suzanne.soy" Date: Fri, 9 Oct 2020 05:27:28 +0100 Subject: [PATCH 2/2] Export of firefox tabs --- export-firefox-tabs.sh | 29 ++++++++++++++++++++++ export-firefox-thumbnails-from-panorama.sh | 8 ++++++ 2 files changed, 37 insertions(+) create mode 100755 export-firefox-tabs.sh create mode 100755 export-firefox-thumbnails-from-panorama.sh diff --git a/export-firefox-tabs.sh b/export-firefox-tabs.sh new file mode 100755 index 0000000..533f162 --- /dev/null +++ b/export-firefox-tabs.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env nix-shell +#!nix-shell --pure -i bash -p dejsonlz4 jq bash -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/fea633695211167753ee732c9087808d0c57461c.tar.gz + +# Usage: ./export-firefox-bookmarks.sh [path/to/.mozilla/firefox/XXXXXXXX.profile] + +set -euET -o pipefail + +if test $# -ge 1; then + profile="$1" +else + # use printf to avoid echo's ambiguity; sort for determinism; use null separator (only byte illegal in UNIX paths, save trailing whitespace with a dummy x (not needed here as the string ends with "default", but a good habit nevertheless) + profile="$(printf "%s"\\0 ~/.mozilla/firefox/*.default | sort -z | head -z -n 1 | tr -d \\0; printf "x")" + profile="${profile%x}" +fi + +if test -e "$profile"/sessionstore-backups/recovery.jsonlz4; then + sessionstore="$profile"/sessionstore-backups/recovery.jsonlz4 +elif test -e "$profile"/sessionstore.jsonlz4; then + sessionstore="$profile"/sessionstore.jsonlz4 +elif test -e "$profile"/sessionstore.js; then + sessionstore="$profile"/sessionstore.js +else + printf "Could not find session store at $profile/sessionstore-backups/recovery.jsonlz4 or $profile/sessionstore.jsonlz4 or $profile/sessionstore.js" + exit 1 +fi + +# TODO: when the name is sessionstore.js, it might not need a decompression with dejsonlz4 ? +# Tabs from all windows are printed together, edit the jq expression to your needs +dejsonlz4 "$sessionstore" | jq '.windows[].tabs[].entries[-1].url' diff --git a/export-firefox-thumbnails-from-panorama.sh b/export-firefox-thumbnails-from-panorama.sh new file mode 100755 index 0000000..4474ae9 --- /dev/null +++ b/export-firefox-thumbnails-from-panorama.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euET -o pipefail + +echo "This is just an example, best not to depend on the user having the panorama plug-in installed." +exit 1. + +dejsonlz4 ~suzanne/apps/chromium/.mozilla/firefox/*.default/sessionstore-backups/recovery.jsonlz4 | jq '.windows[0].tabs[]|.extData["extension:panorama-tab-groups@example.com:thumbnail"]' -r | jq '.thumbnail'