90 lines
3.8 KiB
JavaScript
90 lines
3.8 KiB
JavaScript
// ==UserScript==
|
|
// @name Status.io Selector 2
|
|
// @namespace https://status.io
|
|
// @description Effort to simplify configuration of incidents/maintenance windows
|
|
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
|
|
// @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js
|
|
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
|
|
// @grant GM_addStyle
|
|
// @grant GM_setClipboard
|
|
// @include /^https?://app\.status\.io/dashboard/.*/?(maintenance|incident)/create$/
|
|
// @include /^https?://app\.status\.io/dashboard/.*/?(maintenance|incident)/.*/?edit$/
|
|
// @version 0.0.1
|
|
// ==/UserScript==
|
|
|
|
var zNode = document.createElement ('div');
|
|
zNode.innerHTML = '<button id="canadaCentralButton" type="button">'
|
|
+ 'canadacentral</button><button id = jarvisButton>Jarvis</button><button id=ascButton>ASC</button><button id = kustoButton>Kusto</button> <button id = oneClickButton>1 - Click</button>'
|
|
;
|
|
zNode.setAttribute ('id', 'myContainer');
|
|
document.body.appendChild (zNode);
|
|
|
|
//--- Activate the newly added button.
|
|
document.getElementById ("canadaCentralButton").addEventListener (
|
|
"click", appLensButtonClickAction, false
|
|
);
|
|
document.getElementById ("jarvisButton").addEventListener (
|
|
"click", jarvisButtonClickAction, false
|
|
);
|
|
document.getElementById ("ascButton").addEventListener (
|
|
"click", ascButtonClickAction, false
|
|
);
|
|
document.getElementById ("kustoButton").addEventListener (
|
|
"click", kustoButtonClickAction, false
|
|
);
|
|
document.getElementById ("oneClickButton").addEventListener (
|
|
"click", oneClickButtonClickAction, false
|
|
);
|
|
|
|
function appLensButtonClickAction (zEvent) {
|
|
window.open(appLensURL, "_blank");
|
|
}
|
|
function jarvisButtonClickAction (zEvent) {
|
|
window.open(jarvisURL, "_blank");
|
|
}
|
|
function ascButtonClickAction (zEvent) {
|
|
window.open(ascURL, "_blank");
|
|
}
|
|
function kustoButtonClickAction (zEvent) {
|
|
GM_setClipboard(template, "kusto queries");
|
|
alert(`Kusto queries for ${cluster} have been copied to clipboard!`);
|
|
}
|
|
function oneClickButtonClickAction (zEvent) {
|
|
appLensButtonClickAction(zEvent);
|
|
jarvisButtonClickAction(zEvent);
|
|
ascButtonClickAction(zEvent);
|
|
kustoButtonClickAction(zEvent);
|
|
}
|
|
|
|
//--- Style our newly added elements using CSS.
|
|
GM_addStyle ( multilineStr ( function () {/*!
|
|
#myContainer {
|
|
position: fixed;
|
|
bottom: 0;
|
|
right: 0;
|
|
font-size: 14px;
|
|
background: orange;
|
|
border: 3px outset black;
|
|
margin: 3px;
|
|
opacity: 0.7;
|
|
z-index: 222;
|
|
padding: 5px 5px;
|
|
}
|
|
#myButton {
|
|
cursor: pointer;
|
|
}
|
|
#myContainer p {
|
|
color: red;
|
|
background: white;
|
|
}
|
|
*/} ) );
|
|
|
|
function multilineStr (dummyFunc) {
|
|
var str = dummyFunc.toString ();
|
|
str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
|
|
.replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
|
|
.replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
|
|
;
|
|
return str;
|
|
}
|