AWS-SSO-Console-User-Title-Fix

With AWS SSO the AWS Console Title is ridiculously long, this aims to shorten and list the account name

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         AWS-SSO-Console-User-Title-Fix
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  With AWS SSO the AWS Console Title is ridiculously long, this aims to shorten and list the account name
// @author       John Polansky
// @icon         https://www.google.com/s2/favicons?domain=userscript.zone
// @include      https://console.aws.amazon.*
// @include      https://*.console.aws.amazon.*
// @run-at       document-end
// @inject-into content
// @license      MIT
// @noframes
// @grant window.close
// @grant window.focus
// ==/UserScript==

(function() {
    'use strict';
    // console.log("======================================================")
    // The ClassName might change with updates, find the title in inspect and replace it here
    // let str = document.getElementsByClassName("ThRjn7o-KwO0459UzmvoU")[0].title
    let str = document.getElementsByClassName("_1Vtx1Z7gxtNZJP2MVzVCLO")[2].title
    // console.log(`Element: ${str})
    // AWSReservedSSO_AWSAdministratorAccess_ca3eaf088602997d/[email protected] @ itential-cloudops
    let re = /\w+_(\w+)_(\w+)\/(.*)\s+@\s+(.+)/
    let results = re.exec(str)
    let role = results[1]
    let username = results[3].replace(/@.*$/, "")
    let account = results[4]
    // console.log(`Username: ${username}  Account: ${account}  Role: ${role}`)
    // console.log("======================================================")
    document.getElementsByClassName("_1Vtx1Z7gxtNZJP2MVzVCLO")[2].innerHTML = `${account} / ${role} / ${username}`
})();