diff --git a/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/readme.md b/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/readme.md new file mode 100644 index 0000000000..bae3bc13e8 --- /dev/null +++ b/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/readme.md @@ -0,0 +1,21 @@ +# ServiceNow User Info Bookmarklet + +A simple, client-side bookmarklet to display the current ServiceNow user's details in a pop-up modal. It's designed for developers, testers, and administrators who need to quickly check a user's name, sys_id, and full list of assigned roles + +## Features + +* **Displays Key User Info**: Shows Full Name, User Name, and User ID (sys_id) +* **Shows All Roles**: Lists the complete, sorted array of roles, including inherited roles + + +## How to Use + +1. Create a new bookmark in your browser +2. For the name, enter something memorable like **SN User Info** +3. Copy the code from user_info_bookmarklet.js +4. Paste the code into the **URL** or **Address** field of the bookmark +5. Save the bookmark +6. While on any ServiceNow page, click the bookmark to activate the modal + +image + diff --git a/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/user_info_bookmarklet.js b/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/user_info_bookmarklet.js new file mode 100644 index 0000000000..932f8fb0ce --- /dev/null +++ b/Specialized Areas/Browser Bookmarklets/Show Logged-in User roles/user_info_bookmarklet.js @@ -0,0 +1 @@ +javascript:(function(){var e=null;if("undefined"!=typeof g_user&&g_user.userName)e=g_user;else if("undefined"!=typeof gsft_main&&gsft_main.g_user&&gsft_main.g_user.userName)e=gsft_main.g_user;else if("undefined"!=typeof window.NOW&&window.NOW.user&&"undefined"!=typeof window.ux_globals&&window.ux_globals.session)try{e={fullName:window.ux_globals.session.output.user.fullName,userName:window.ux_globals.session.output.user.userName,userID:window.NOW.user.userID,allRoles:window.ux_globals.session.output.user.roles}}catch(o){e=null}if(!e)return void alert("Could not find a ServiceNow user object (g_user, gsft_main.g_user, or Workspace objects). Are you on a ServiceNow page and logged in?");var n=document.getElementById("sn-user-modal");n&&n.parentNode.removeChild(n);var o=e.allRoles.filter(function(e){return e}).sort().join("
"),t='

User Details

Full Name: '+e.fullName+'

User Name: '+e.userName+'

User ID (sys_id): '+e.userID+'

All Roles ('+e.allRoles.filter(function(e){return e}).length+')

'+o+"
",l=document.createElement("div");l.id="sn-user-modal";var d="#sn-user-modal-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.6);z-index:9999;}#sn-user-modal-content{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#fff;padding:25px;border-radius:8px;box-shadow:0 5px 15px rgba(0,0,0,0.3);width:550px;max-width:90%;max-height:90vh;z-index:10000;box-sizing:border-box;}#sn-user-modal-body{max-height:calc(90vh - 100px);overflow-y:auto;}#sn-user-modal-close{position:absolute;top:10px;right:15px;font-size:28px;font-weight:bold;cursor:pointer;color:#888;line-height:1;}#sn-user-modal-close:hover{color:#000;}";function i(){var e=document.getElementById("sn-user-modal");e&&e.parentNode.removeChild(e)}l.innerHTML="
×
'+t+"
",document.body.appendChild(l),document.getElementById("sn-user-modal-close").addEventListener("click",i),document.getElementById("sn-user-modal-backdrop").addEventListener("click",i)})();