thegreatsuspender icon indicating copy to clipboard operation
thegreatsuspender copied to clipboard

Sifting thru exported history file using perl, converting TGS links into TMS, converting session buddy file

Open Blobbel opened this issue 4 years ago • 4 comments

Yet another approach, more old school but perhaps someone has use for it

TGS = the great suspender (now disabled) TMS = the marvellous suspender (available here: https://chrome.google.com/webstore/detail/the-marvellous-suspender/noogafoofpebimajpfpamcfhoaifemoa/) Plugin to export history here: https://chrome.google.com/webstore/detail/export-historybookmarks-t/dcoegfodcnjofhjfbhegcgjgapeichlf

History file

step 1: export history as json step 2: use perl to read that file, find references to tabs suspended by TGS, replace to refer to TMS, write to new html file step 3: open and review that file to see what suspended tabs you might want to restore

open IN, "YOUR_EXPORTED_HISTORY_FILE_NAME_HERE.json";

# find
# chrome-extension://klbibkeccnjlkjkiokjodocebajanakg
# and dates without parsing json

$i = 0;
$foundflag = 0;
while (<IN>) {
	if(m#"url": "(chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/.+)"#) {
		$urls[$i] = $1;
		$foundflag = 1;
	}
	if($foundflag) {
		if(m#"lastVisitTimeUTC": "(.+)"#) {
			$dates[$i] = $1;
			$foundflag = 0;
			$i++;
		}
	}
}
close IN;

$i=0;
foreach $u (@urls) {
	# change URL to marvellous suspender
	$u =~ s#klbibkeccnjlkjkiokjodocebajanakg#noogafoofpebimajpfpamcfhoaifemoa#g;

	# make hash by date value
	$da{$dates[$i]} = $u;
	$i++;
}

# reverse sort and make urls
open OUT, ">YOUR_EXPORTED_HISTORY_FILE_NAME_HERE_TGS_links.html";
print OUT "<html><body>";
foreach(reverse sort keys %da) {
	print "*";
	print OUT $_ . ' <a href="' . $da{$_} . '" target="_blank">' . $da{$_} . '</a><br>' . "\n";
}
print OUT "</html></body>";

Session buddy file

step 1: export all your session buddy sessions (likely full of suspended TGS tabs) as json step 2: use perl to read that file, find references to tabs suspended by TGS, replace to refer to TMS, write to new session buddy json file step 3: delete your old sessions (shift-click the sessions in left pane like with any object, and hit delete) step 4: import the new file

open IN, "YOUR_SESSION_BUDDY_EXPORT_FILE_NAME_HERE.json";
open OUT, ">YOUR_SESSION_BUDDY_EXPORT_FILE_NAME_HERE_TGS_replaced.json";

# just replace klbibkeccnjlkjkiokjodocebajanakg w noogafoofpebimajpfpamcfhoaifemoa

$i = 0;
$foundflag = 0;
while (<IN>) {
	s#klbibkeccnjlkjkiokjodocebajanakg#noogafoofpebimajpfpamcfhoaifemoa#g;
	print OUT;
}
close IN;

NB, I'm not responsible if you screw up your session system, make sure you know what you are doing of course. Will delete this if something is broken but I don't have much to lose so I will try it ...

Blobbel avatar Feb 05 '21 09:02 Blobbel

Well, I'd suggest you write a Javascript version of your PERL one instead; why install PERL since Javascript is there?

cypherinfo avatar Feb 05 '21 11:02 cypherinfo

But I'm very bad at javascript.... and everyone ought to have perl installed :-)

(It's not a bad idea, someone should perhaps do it, I have no idea how to do the file handling though.

I generally like the idea of operating on files rather than on internal browser objects, which may be a bit ephemeral, especially in this kind of situation where the browser just rips the rug from under your feet)

Blobbel avatar Feb 05 '21 12:02 Blobbel

But I'm very bad at javascript.... and everyone ought to have perl installed :-)

(It's not a bad idea, someone should perhaps do it, I have no idea how to do the file handling though.

I generally like the idea of operating on files rather than on internal browser objects, which may be a bit ephemeral, especially in this kind of situation where the browser just rips the rug from under your feet)

May be a request on the https://chrome.google.com/webstore/detail/the-marvellous-suspender/noogafoofpebimajpfpamcfhoaifemoa/ of the TMS?

cypherinfo avatar Feb 05 '21 12:02 cypherinfo

For those interested in an in-browser solution dealing with the history at least, there is now this, right next door:

https://github.com/greatsuspender/thegreatsuspender/issues/1319

Blobbel avatar Feb 05 '21 20:02 Blobbel