There are a bunch of web apps that I generally like to keep open when working on my computer. Mostly messengers: Slack, multiple instances of mattermost, etc. But I usually make a mess of my browser windows and tabs, so I end up opening these apps multiple times or accidentally closing them. This is my attempt to nudge me back to sanity.
- Open all my important apps in a single chromium window with a single click
- Prevent me from accidentally closing any of these apps
- Prevent me from cluttering up this window
You might be able to translate some of this to windows and other browsers, but this guide was created with:
- Chromium
- Linux
Top rigt corner (Next to the vertical dots) -> Add profile (Referred to as apps-profile)
In a chromium window using the apps-profile.
Goto: chrome://settings/onStartup
-> Open a specific page or set of pages
Hint: The tabs will open in the order in which you add them here, but you can not reorder them here! :(
Install the Tampermonkey Extension.
Add this user script:
// ==UserScript==
// @name PreventClose
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prompt before closing tab
// @author Niklas Beierl
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const originsToPrompt = [];
function onBeforeUnload(e) {
e.returnValue = "Modern Browsers will ignore this string.";
}
window.addEventListener('beforeunload', onBeforeUnload);
})();
This activates the "Changes you made may not be saved."-prompt on any pages you will choose in the next step:
In the settings tab for that user script, add all of your apps, to "User matches". So if you want to prevent yourself from closing
tabs on https://some-app.tld
add https://some-app.tld/*
, e.g.: https://app.slack.com/*
Now we have introduced a bit of an annoying issue: By default, chromium will open any new window with the least recently used profile.
But I only want to open a window for that profile when explicitly selecting it in the profile menu! By default, new windows should open with my "Default" profile.
On linux you can simply add --profile-directory="Default"
to /home/<user>/.config/chromium-flags.conf
to achieve that.
See this stackoverflow post for
a more detailed explanation. You can of course also have a non-"Default" profile open by default. ;)