Skip to content

Instantly share code, notes, and snippets.

@PandelisZ
Created June 6, 2024 10:28
Show Gist options
  • Save PandelisZ/39a548ab0bf64993c4f295215438bba7 to your computer and use it in GitHub Desktop.
Save PandelisZ/39a548ab0bf64993c4f295215438bba7 to your computer and use it in GitHub Desktop.
Script to have the TV autolog back into the grafana dashboard unattended
// ==UserScript==
// @name LoginToGrafana
// @namespace http://tampermonkey.net/
// @version 2024-06-06
// @description try to take over the world!
// @author You
// @match https://*.grafana-workspace.eu-west-2.amazonaws.com/login
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// ==/UserScript==
function runWhenReady(readySelector, callback) {
var numAttempts = 0;
var tryNow = function() {
var elem = document.querySelector(readySelector);
if (elem) {
callback(elem);
} else {
numAttempts++;
if (numAttempts >= 34) {
console.warn('Giving up after 34 attempts. Could not find: ' + readySelector);
} else {
setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
}
}
};
tryNow();
}
(function() {
'use strict';
console.log('tampermonkey running');
runWhenReady('#pageContent > div.css-j6t0te > div > div > div.css-1f4iiuo > div > div > div:nth-child(2) > a', (elem) => {
elem.click()
});
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment