Last active
September 21, 2024 20:16
-
-
Save HorridModz/948389366d63d92352beefe22764063f to your computer and use it in GitHub Desktop.
Bookmarklet - Google Switch Account And Redirect
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
javascript:/* | |
If you've ever tried to open a google service's website and had it restricted (no access, account blocked from service, unavailable under 18, etc.), but it's because it automatically opened with your default account and not the one you want, this bookmarklet is an easy way to solve the problem. It will open Google's "Choose an account" dialog, allowing you to select your desired account, and then open your google site with that account selected. | |
Thanks to https://stackoverflow.com/a/76933666 for the trick; code is by me | |
Full code (doesn't work as bookmarklet): | |
function bookmarklet() { | |
var site = window.prompt("Link to desired site"); | |
if (site == null) { | |
return; | |
} | |
if (!site.startsWith("https://")) { | |
site = "https://" + site; | |
} | |
new URL(site); // Let it fail silently to exit bookmarklet | |
window.location="https://accounts.google.com/AccountChooser?continue=" + encodeURIComponent(site); | |
} | |
bookmarklet(); | |
*/ | |
javascript:(function(){var site=window.prompt("Link to desired site");if(site==null){return;}if(!site.startsWith("https://")){site="https://"+site;}try{new URL(site);}catch(e){alert("Invalid URL");return;}window.location="https://accounts.google.com/AccountChooser?continue="+encodeURIComponent(site);})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment