Last active
July 31, 2023 15:29
-
-
Save michaelfm1211/388d7eb03f971dbb0888905fbcef1582 to your computer and use it in GitHub Desktop.
Tampermonkey Userscript to use HTML Gmail as the default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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