Skip to content

Instantly share code, notes, and snippets.

@JLarky
Last active February 11, 2021 04:08
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 JLarky/0385d22305c86ed5ca05b254a1e902ac to your computer and use it in GitHub Desktop.
Save JLarky/0385d22305c86ed5ca05b254a1e902ac to your computer and use it in GitHub Desktop.
How to restore the great suspender tab urls: run this script, copy current url and paste it right back. Uses `npm install -g clipboard-cli` (irony isn't lost on me).

This should work on any OS but I only tested linux and mac os. You have to have Deno and Node.js installed

npm install -g clipboard-cli

deno run --allow-run https://gist.githubusercontent.com/JLarky/0385d22305c86ed5ca05b254a1e902ac/raw/e39402436dc04fbd52f19d1642ea828ef102d540/clipboard.ts

Once the script is running each time that you copy chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html (for example chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=%D0%92%D1%85%D0%BE%D0%B4%D1%8F%D1%89%D0%B8%D0%B5%20(186)%20-%20airelain%40gmail.com%20-%20Gmail&pos=0&uri=https://mail.google.com/mail/u/0/#inbox) URL into clipboard it will be replaced with original URL that you had suspended (you can see it in &uri=...).

Here in the video you can see that it's pretty easy to use: https://user-images.githubusercontent.com/7026/107090038-759e1280-67b4-11eb-9d2d-01c635af37cd.mp4

  1. select URL in the address bar
  2. press ctrl+c
  3. press ctrl+v
  4. press Enter
  5. repeat with another tab

Q&A:

is it safe to use --allow-run?

no, please check the code that you run from the internet

wow, can't believe how bad this code is

me neither, but it works, please create a better one and tweet to me https://twitter.com/JLarky

import { sleep } from "https://deno.land/x/sleep/mod.ts";
const read = async () => {
const cmd = Deno.run({
cmd: ["clipboard"],
stdout: "piped",
stderr: "piped",
});
const output = await cmd.output(); // "piped" must be set
const outStr = new TextDecoder().decode(output);
cmd.close(); // Don't forget to close it
return outStr;
};
const write = async (text: string) => {
const cmd = Deno.run({
cmd: ["clipboard"],
stdin: "piped",
});
await cmd.stdin.write(new TextEncoder().encode(text));
await cmd.stdin.close();
const { code } = await cmd.status();
cmd.close(); // Don't forget to close it
console.log(code);
};
while (true) {
const url = await read();
const urlExample =
"chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=%D0%92%D1%85%D0%BE%D0%B4%D1%8F%D1%89%D0%B8%D0%B5%20(186)%20-%20airelain%40gmail.com%20-%20Gmail&pos=0&uri=https://mail.google.com/mail/u/0/#inbox";
let paramsString = "";
try {
const parsed = new URL(url);
if (parsed.protocol === "chrome-extension:") {
paramsString = parsed.hash;
}
} catch (e) {
// ignore Invalid URL
}
if (paramsString) {
const newUrl = new URLSearchParams(paramsString).get("uri");
if (newUrl) {
console.log(newUrl);
await write(newUrl);
}
}
await sleep(0.2);
}
@cypherinfo
Copy link

cypherinfo commented Feb 7, 2021

Glad to see the first Javascript code that tries to fix that issue.
What about all those who were using Session Buddy along with TGS as in this video:: https://youtu.be/Ud1MqzZ_Pbs
May you upgrade your code in order to help fix it too? I mean to automate the fx without any manual intervention.
Thank you.

@JLarky
Copy link
Author

JLarky commented Feb 11, 2021

Glad to see the first Javascript code that tries to fix that issue.
What about all those who were using Session Buddy along with TGS as in this video:: https://youtu.be/Ud1MqzZ_Pbs
May you upgrade your code in order to help fix it too? I mean to automate the fx without any manual intervention.
Thank you.

You should try to use instructions from this answer https://superuser.com/a/1616092/49712 you can export your tabs into a text file, fix URLs and import them back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment