Skip to content

Instantly share code, notes, and snippets.

@DestyNova
Created September 8, 2013 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DestyNova/6488570 to your computer and use it in GitHub Desktop.
Save DestyNova/6488570 to your computer and use it in GitHub Desktop.
Swap the open and closed windows in Firefox's saved session file (sessionstore.js). Needs the extremely fast ''dkjson'' library (the session file is a big JSON string).
json = require('dkjson')
function main(max_depth)
print('Reading file...')
local session = assert(io.open('sessionstore.js', 'r'))
local session_data = session:read('*all')
print('Parsing ('..#session_data..' bytes)...')
local obj, pos, err = json.decode(session_data, 1, json.null)
if err then error(err) end
print('Success! table size: '..#obj, pos, err)
-- swap open/closed windows
print('Decoded, swapping closed and open windows')
local old_windows = obj.windows
obj.windows = obj._closedWindows
obj._closedWindows = old_windows
print('Encoding')
local outf = assert(io.open('sessionstore-rec-fixed.js', 'w'))
outf:write(json.encode(obj))
outf:close()
return obj
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment