Skip to content

Instantly share code, notes, and snippets.

@devna13
Last active September 12, 2023 15:41
Show Gist options
  • Save devna13/12e4fc1df87016c6cab2013ac66d1170 to your computer and use it in GitHub Desktop.
Save devna13/12e4fc1df87016c6cab2013ac66d1170 to your computer and use it in GitHub Desktop.
Activate https://portal.azure.com/ PIM via TamperMonkey script
// ==UserScript==
// @name Role activate
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://portal.azure.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=azure.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("************** HERE AZ ROLE ***********");
setTimeout(() => {
activateRole('role-2');
}, 3000);
setTimeout(() => {
activateRole('role-1');
}, 5000);
function activateRole(roleName){
console.log("Activating: " + roleName);
var found = $("tr:contains('"+ roleName+"') td:last-child a");
if (!found) {
console.log("role table not found.");
return;
}
found[0].click();
setTimeout(() => {
console.log(" Time out...");
var txtArea = $(".azc-textarea.azc-input");
if (!txtArea) {
console.log(" text area not found.");
return;
}
//var form= txtArea.closest("form");
//console.log('form', form);
txtArea.on("input", function() {
console.log(" Dirty call back...");
$(this).data("dirty", true);
$("div[title='Activate']").click();
});
txtArea.val("Monitoring");
txtArea.trigger('input');
}, 4000);
// Your code here...
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment