Skip to content

Instantly share code, notes, and snippets.

@santaklouse
Last active April 7, 2022 21:48
Show Gist options
  • Select an option

  • Save santaklouse/64f99a48bba2cd206278491b2829d70e to your computer and use it in GitHub Desktop.

Select an option

Save santaklouse/64f99a48bba2cd206278491b2829d70e to your computer and use it in GitHub Desktop.
Great suspender fix tab urls after import to another chrome

You can:

just update tab urls to original urls

  1. need to open any extension settings page (url should starts from chrome-extension://)
  2. open DevTools and execure this code in console:
chrome.tabs.query(
	{url: "chrome-extension://*/suspended.html*"},
	tabs => tabs.forEach(t => 
		chrome.tabs.update(t.id, {url: t.url.split("&uri=").slice(1).join("")})
	)
)

  1. open suspender settings page

  2. open DevTools and execure this code in console:

// by default script just shows in console new urls for tabs
// need to change true => false in line below in order to changes take effect
RUN_IN_DEBUG_MODE = true;

(() => {
    const _buldSuspendedUrl = (tabUrl, base) => 
    	String(new URL("/html/suspended.html#" + tabUrl.split("suspended.html#").slice(1).join(''), base))
    

    const updateTabUrl = baseExtensionUrl => 
        tab => 
   	    RUN_IN_DEBUG_MODE
	        ? console.log(tab.id, _buldSuspendedUrl(tab.url, baseExtensionUrl))
	        : chrome.tabs.update(tab.id, {url: _buldSuspendedUrl(tab.url, baseExtensionUrl)})
    ;
    
    chrome.tabs.getCurrent(tab => {
        const base = (new URL(tab.url)).origin;
    
        chrome.tabs.query(
            {url: "chrome-extension://*/suspended.html*"},
            tabs => tabs.forEach(updateTabUrl(base))
        );
    });

})();

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