Skip to content

A cross-browser extension to suspend inactive / unused tabs by "hiding" them behind a static, generic browser error page. Basically to suspend https://moshe-gr.com, it will be redirected to http://localhost:0/#https://www.moshe-gr.com (try it ;) ).

License

Notifications You must be signed in to change notification settings

VehpuS/simple-cross-browser-suspender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Simple Cross Browser Suspender Extension

Summary

A cross-browser extension to suspend inactive / unused tabs by "hiding" them behind a static, generic browser error page. Basically to suspend https://moshe-gr.com, it will be redirected to http://localhost:0/#https://www.moshe-gr.com (try it ;) ).

Background

The great suspender (RIP).

My own TL;DR

The great suspender was an extension that would automatically replace an open tab with a static, low memory page that would redirect back to the original on demand or after a set idle time. After a change of ownership, it was abused to contain malware, and therefore removed by Google.

Looking to avoid another extension by and unknown developer (who can always change), I opted to find a safer solution. I believe I have found it and want to share it in a way that can let others use / replicate it for their own benefit, at the level of knowledge and safety they require.

Why is this solution safer

  • No static page - cannot be abused without changing the logic in a noticeable way.

  • Hash parameter - not sent to a server by the browser, by design.

  • I decided to use localhost:0 as a "host" to keep things local, and on a port that shouldn't conflict with other services / local servers.

  • Simple code base - easy to fork, install manually, and if necessary - replicate.

    • The core of the script boils down to:

      const suspendPrefix = "https://localhost:0/#";
      const toggleSuspendUrl = (pageUrl) =>
        pageUrl.startsWith(suspendPrefix)
          ? pageUrl.replace(suspendPrefix, "")
          : `${suspendPrefix}${pageUrl}`;
      if (browser) {
        browser.browserAction.onClicked.addListener((tab) => {
          browser.tabs.update(tab.id, { url: toggleSuspendUrl(tab.url) });
        });
      }
  • The API I'm using doesn't require running Javascript code on the web page in the tab - just to get a page's URL. This makes the abuse potential minimal, and is reflected in the extensions limited permissions.

  • Advanced features, if/when added, will be "opt in" via a separate installation (on stores if / when I upload them) and branch (or possibly repository) - to always provide a stable, simple, and secure base version.

Known issues

Resources for Potentially Relevant APIs

Cross Browser APIs

Base capability - read URL + redirect manually

Add on features (will be a separate branch + extension)

  • Schedule code to run at a specific time in the future using the alarm API.
  • Idle recognition via the idle API.

Incompatabilies

Examples

Mobile

Handling error pages in browsers (current solution works without this)

Chrome error pages take over the window.location.href attribute https://stackoverflow.com/questions/29989031/getting-the-current-domain-name-in-chrome-when-the-page-fails-to-load

I used a different selector when trying to run code from the page (not the current solution - recorded here in case it is needed):

document.querySelector(`[jscontent="failedUrl"]`)?.innerText;

About

A cross-browser extension to suspend inactive / unused tabs by "hiding" them behind a static, generic browser error page. Basically to suspend https://moshe-gr.com, it will be redirected to http://localhost:0/#https://www.moshe-gr.com (try it ;) ).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published