VehpuS / simple-cross-browser-suspender

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 ;) ).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Cross Browser Suspender Extension

Link to Chrome Web Store Link to Firefox Web Store Link to Edge Web Store Simple Suspender - A multi browser tab suspender - safely and privately | Product Hunt

Note: The badge for edge is an unofficial one made by Liozon. App icon from https://pixabay.com/vectors/suspension-bridge-golden-gate-bridge-161705/

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 ;) ).

Store Links

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 an 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

Manual Installation (running from source)

Chrome

  1. Clone the repo from Github.

  2. Go to the Manage Extensions page.

  3. Toggle on Developer Mode (top right corner).

  4. Load the unpacked extension from the manifest-v3 folder (manifest-v2 will work too for now).

Edge

  1. Clone the repo from Github.

  2. Go to the Manage Extensions page.

  3. Toggle on Developer Mode (top right corner).

  4. Load the unpacked extension from the manifest-v3 folder (manifest-v2 will work too for now).

Firefox

  1. Clone the repo from Github.

  2. Go to the Mozilla debugging page.

    1. If the URL doesn't work:

      1. Got to the Add-ons Manager page.

      2. Select the gear icon next to "Manage Your Extensions" and select "Debug Add-ons".

  3. Press "Load Temporary Add-on..." and select the manifest-v2 folder (Mozilla doesn't support manifest-v3 at the time [July 2021]).

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 ;) ).

License:MIT License


Languages

Language:JavaScript 100.0%