Skip to content

Instantly share code, notes, and snippets.

@theapache64
Created August 26, 2022 06:31
Show Gist options
  • Save theapache64/3b031b948efe14c45940c4fdd9f8fdba to your computer and use it in GitHub Desktop.
Save theapache64/3b031b948efe14c45940c4fdd9f8fdba to your computer and use it in GitHub Desktop.
Auto redirect to different account - crashlytics
// Extension URL RegEx : https:\/\/console.firebase.google.com\/u\/0\/.+
var accountIndex = 1 // Auto redirect account index
var newUrl = "https://console.firebase.google.com/u/"
+ accountIndex
+ window.location.toString().split("/u/0")[1]
window.location = newUrl
@tajchert
Copy link

Thanks!

I ended up a bit modifying it so not only /u/0 are handled, as sometimes somebody will send you a link and they might have a different profile numeration than you (ex. company profile can be 3 and not 1).

I wanted to avoid using REGEX so that is why it doesn't handle >9 profile digits (perf but also my sanity and I have never received link with profile number higher than one-digit number).

var currentUrl = window.location.toString();
var websiteUrl = "https://console.firebase.google.com/u/"
var companyGoogleProfileIndex = 1
if(currentUrl.includes(websiteUrl)) { // This is not needed if we use Tempermonkey match parameter
    // So we are on Firebase domain
    if(!currentUrl.includes(websiteUrl + companyGoogleProfileIndex.toString())) {
        // but using different account than company one, lets fix this, this will fail if you have link with double-digit profile number
        window.location = "https://console.firebase.google.com/u/" + companyGoogleProfileIndex + currentUrl.substring(39, currentUrl.length);
    }
}

As I'm using Tempermonkey script executes only on websites fulfilling match argument, but as somebody might copy without reading I left checking if we are on Firebase domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment