Best copy your sessionstore.js to /tmp/ and only work on that version.
Keep the original as backup somewhere.
When you want to try if the resulting created cleaned-up sessionstore.js works for your Firefox or Palemoon you have to exit all running instances of the browser first (do a backup of your sessionstore.js in your user profile folder) and copy the created sessionstore.js.new to "/your/user-profile-folder/sessionstore.js" and then start your FFx or PM anew.
In case of PM, your profile folder would be something like this:
Code: Select all
/home/guest/.moonchild productions/pale moon/RANDOM.default
It is not self-explanatory how it works. - see below how I used it for a sessionstore cleanup - unless you understand what stdin and stdout means and how to use these to run the script.
The code:
Code: Select all
#! /usr/bin/env python
import json
import sys
s = json.load(sys.stdin)
del s["_closedWindows"]
for w in s["windows"]:
del w["_closedTabs"]
for t in w["tabs"]:
del t["entries"][:-1]
try:
del t["storage"]
except:
pass
for key in "children", "owner_b64":
try:
del t["entries"][0][key]
except:
pass
json.dump(s, sys.stdout)
Prior executing it, I copied my sessionstore.js to /tmp
Code: Select all
root@porteus:/tmp# ls -o sessionstore.js*
-rw------- 1 guest 76651 2022-11-02 07:41 sessionstore.js
Code: Select all
root@porteus:/tmp# cleanup_sessionstore.py < sessionstore.js > sessionstore.js.new
root@porteus:/tmp# ls -o sessionstore.js*
-rw------- 1 guest 76651 2022-11-02 07:41 sessionstore.js
-rw-r--r-- 1 root 15421 2022-11-02 07:47 sessionstore.js.new
![Magic :magic:](./images/smilies/magic.gif)
To be able to execute cleanup_sessionstore.py like I did it must be executable and in one of your folders that are part of your $PATH.
I recommend using /usr/local/bin as folder for it since this is the dedicated place for local binaries and scripts on an *IX* system.
To quote wikipedia on that: https://en.wikipedia.org/wiki/Unix_file ... ory_layout
Code: Select all
/usr
/local
Resembles /usr in structure, but its subdirectories are used for additions
not part of the operating system distribution, such as custom programs
or files from a BSD Ports collection. Usually has subdirectories such as
/usr/local/lib or /usr/local/bin.
Code: Select all
root@porteus:/tmp# ls -l /usr/local/bin/cleanup_sessionstore.py
-rwxr-xr-x 1 root root 439 2013-06-07 22:44 /usr/local/bin/cleanup_sessionstore.py
root@porteus:/tmp# file /usr/local/bin/cleanup_sessionstore.py
/usr/local/bin/cleanup_sessionstore.py: Python script, ASCII text executable
CAVE! Using the same file name as input and as output file would result in disaster, as in: the file contents would be erased. Look for yourself, I created a sessionstore.js.FAIL to demonstrate that:
Code: Select all
root@porteus:/tmp# cp sessionstore.js sessionstore.js.FAIL
root@porteus:/tmp# ls -o sessionstore.js.FAIL*
-rw------- 1 guest 76651 2022-11-02 07:41 sessionstore.js.FAIL
root@porteus:/tmp# cleanup_sessiostore.py < sessionstore.js.FAIL > sessionstore.js.FAIL
Traceback (most recent call last):
File "/usr/local/bin/cleanup_sessiostore.py", line 4, in <module>
s = json.load(sys.stdin)
File "/usr/lib64/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
root@porteus:/tmp# echo $?
1
root@porteus:/tmp# ls -o sessionstore.js.FAIL*
-rw------- 1 guest 0 2022-11-02 08:18 sessionstore.js.FAIL