rberenguel / bestBefore

Automatically expire Chrome tabs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best before

What is this?

This extension adds an expiry date to tabs: when they expire they are automatically closed.

By activating the extension you can customise the expiry of a particular tab, or set a tab as not expiring, particularly useful for pinned tabs. By default, any new tab should get 12 hours, this default can be customised.

Hover over the extension to see exactly how much time a tab has left. The extension badge shows the "topline time left", rounding up. So, it will say "12 hours" when it's 11 hours 50 minutes. As soon as it goes below 60 minutes it will stop rounding up and show in red, in case you need to extend it.

I take no responsibility on any data you might lose by using this extension!


Caveats

The code is not great to look at, I wrote (or more like, coerced Gemini to write) this quickly to see if I liked it.

I don't promise new releases are backward compatible. Although I will try to, now that I use the stored data for an overview page, I may need to change it and I assume I'm the only user.

Important

When Chrome gets updated or restarts (and you "restore all tabs"), tab ids are lost. Every time you open the tab info page (the "i" link in the extension popup) and once every minute I run a naive reconciliation, that tries to match tabs that had an expiry on them with what is available in storage, by URL. On a match, I update the real existing tab with that information (and delete the old entry). This should work well enough, but keep it in mind.

Caution

Default expiries also apply to "apps" that are actually skins of Chrome (i.e. they provide access to extensions). So, if you see some app strangely close itself check if it has some sort of extensions menu hidden, or whether it shows as a tab in the Tab Information page. I have added a "catch" for tabs created in such apps, and they should get "forever" as duration, but I'm not 100% sure how reliable the trick is.


Buy Me A Coffee


How it looks like in Chrome (a bit outdated, it looks better now, but I didn't bother creating new screenshots yet)

A tab with no expiry

A tab with less than 2 hours left, but still enough to do something about it

A tab with 20 minutes left, the amber countdown starts with 1 hour left

A tab with 2 minutes left, the red countdown starts with 15 minutes left

Options popup

Extension popup

Extension hover title

Why?

I collect way too many tabs. I hope this will help me avoid that.

Bugs, etc.?

Sometimes pressing the quick-set buttons does not work, but I haven't found out why yet. Every time it has passed I was in the middle of something else, and on the second press it works. A small annoyance I happily pay knowing any tab I didn't really need today won't be on my computer by tomorrow morning.

Otherwise, I have used this for almost a week while improving the usage experience and I have been extremely happy with it. If you use it and find improvements I'll be happy to hear it but remember this is open source, and I created this extension for me on the assumption nobody else might need it. So it should fulfill my usecases, not anybody else's. The best part though is that you can fork this repository and just install your own tweaked version manually just like this one. Freedom to tinker, freedom to change!

Installing

  • Clone or download (remember then to unzip) this repository somewhere
  • In Chrome, More tools > Extensions
  • In Chrome > Extensions, Enable developer mode
  • Click Load unpacked, then browse to where you downloaded the repository
  • Optional but recommended: pin the extension.

What about Safari?

For Safari on Mac, the Safari extension converter (here) from Apple will generate a usable extension, although the styling looks better in Chrome, even if I didn't do much in terms of styling. I might fix that. For Safari on iOS the extension kind of works, but not completely and the user experience is sub-par. But I'm positively surprised that it works at all without any effort. I might work on making it nicer on Safari, because I use Chrome for work, but I use Safari on my personal devices (for battery reasons mostly).

Attribution

About

Automatically expire Chrome tabs

License:MIT License


Languages

Language:JavaScript 97.4%Language:HTML 1.5%Language:CSS 1.1%