Skip to content

Instantly share code, notes, and snippets.

@fosemberg
Last active January 23, 2020 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fosemberg/a983c5868814a9be677c5a83c844c3f5 to your computer and use it in GitHub Desktop.
Save fosemberg/a983c5868814a9be677c5a83c844c3f5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Mondit
// @namespace http://tampermonkey.net/
// @version 0.6
// @description try to take over the world!
// @author You
// @match https://mondit.alpari-ru.dom/monitoring/app
// @grant none
// ==/UserScript==
(function() {
'use strict';
const isBlackBackground = true;
const isFilterOn = true;
const css = {
blackBackground: `#app {background: black !important;}`,
dataFilter: `#app > .table tr {display: none;}`,
custom: `
.time.time {
right: 0;
color: gray;
background: black;
}`
};
const updateTimeout = 200;
const filterText = 'bali_asv';
const getTable = () => document.querySelector('table');
const getTrsFromTable = table => table.querySelectorAll('tr');
const checkIsBaliText = text => text === filterText;
const checkIsBali = tr => checkIsBaliText(tr.firstElementChild.innerText);
const showTr = tr => tr.style.display = 'table-row';
const showBali = (table = getTable()) => getTrsFromTable(table).forEach(tr => checkIsBali(tr) && showTr(tr));
const addStylesToPage = css => {
const head = document.head;
const style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
}
addStylesToPage(css.custom);
if (isFilterOn) {
const showBaliInterval = setInterval(showBali, updateTimeout);
addStylesToPage(css.dataFilter);
}
if (isBlackBackground) {
addStylesToPage(css.blackBackground);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment