Skip to content

Instantly share code, notes, and snippets.

@michaelfm1211
Last active July 31, 2023 15:29
Show Gist options
  • Save michaelfm1211/388d7eb03f971dbb0888905fbcef1582 to your computer and use it in GitHub Desktop.
Save michaelfm1211/388d7eb03f971dbb0888905fbcef1582 to your computer and use it in GitHub Desktop.
Tampermonkey Userscript to use HTML Gmail as the default
// ==UserScript==
// @name Use HTML Gmail as Default
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Set the HTML version of Gmail as the default, and add an account switcher
// @author Michael M
// @match https://mail.google.com/mail/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// rewrite the URL to use the HTML version
if (!location.href.includes('/h')) {
location.href = location.href + '/h/';
}
window.onload = function() {
// get the current user ID from the URL
const currUser = location.href.match(/\/u\/(\d)/)[1];
// add a switcher to quickly switch accounts
const switcher = document.createElement('a');
switcher.style.margin = '10px';
switcher.textContent = 'Switch Account';
switcher.href = location.href.replace(/\/u\/\d/, '/u/' + currUser + 1);
document.getElementsByClassName('gbi')[0].appendChild(switcher);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment