Created
September 8, 2013 21:31
-
-
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).
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
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