Created
May 7, 2025 19:22
-
-
Save seletskiy/f87590a2057cac327c5f9fdd8156d9ae to your computer and use it in GitHub Desktop.
Convert plaintext list of URLs to firefox session restore file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| { | |
| echo '{"version":["sessionrestore",1],"windows":[{"tabs":[' | |
| while read url; do | |
| echo '{' | |
| echo '"entries":[{"url":"'$url'"}]' | |
| echo '},' | |
| done <links | |
| echo '{}' | |
| echo ']' | |
| echo '}]' | |
| echo '}' | |
| } >links.1 | |
| read size _ < <(wc -c links.1) | |
| a=$((size % 256)) | |
| b=$(((size / 256) % 256)) | |
| c=$(((size / 256 / 256) % 256)) | |
| { | |
| printf 'mozLz40\0' | |
| printf '\x'$(printf '%x' $a) | |
| printf '\x'$(printf '%x' $b) | |
| printf '\x'$(printf '%x' $c) | |
| printf '\0' | |
| lz4 --no-frame-crc <links.1 | tail -c+12 | head -c-4 | |
| } >sessionstore.jsonlz4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment