Machinemetrics Reports on load click today drop down

This is an example for Machine Metrics reports, to automatically set the desired report view, hide the graph, expand two machines, and to reload the page on an interval.

当前为 2023-05-03 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Machinemetrics Reports on load click today drop down
// @namespace    https://app.machinemetrics.com/
// @version      0.11
// @description  This is an example for Machine Metrics reports, to automatically set the desired report view, hide the graph, expand two machines, and to reload the page on an interval.
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.js
// @author       rickzabel
// @match        https://app.machinemetrics.com/app/reports/builder?id=3056
// @grant        none
// @license MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    const myInterval = setInterval(myTimer, 3000);
    const myInterval2 = setInterval(myTimer2, 3000);

    function myTimer() {
        var x = document.querySelector('.SelectBase__MenuItem-sc-1p5n5sa-7');
        if (x != null) {

            //call function to stop timer
            myStopFunction()

            //click the dropdown for the desired date range
            document.querySelector('#today.SelectBase__MenuItem-sc-1p5n5sa-7').click();
            //document.querySelector('#last-2-days.SelectBase__MenuItem-sc-1p5n5sa-7').click();
            //document.querySelector('#last-month.SelectBase__MenuItem-sc-1p5n5sa-7').click();

        }
    }

    function myStopFunction() {
        clearInterval(myInterval);
    }

    function myTimer2() {
       var x2 = document.querySelector('#table-row-undefined div div .Cells__EntityText-sc-1o23ezk-3.bIOdKK');

        if (x2 != null) {
            //stop timer
             myStopFunction2()
        }

        //Hide the chart
        document.querySelector('#hide-chart').click();

        //expand first shift
        document.querySelector("#table-row-undefined div div .Cells__EntityText-sc-1o23ezk-3.bIOdKK").click();

        //expand 2nd shift
        document.querySelector("#table-row-undefined ~ div div div .Cells__EntityText-sc-1o23ezk-3.bIOdKK").click();
    }

    function myStopFunction2() {
        clearInterval(myInterval2);
    }


    //reload ever 24 hours
    //setTimeout(MyReload, 86400);

    //clear reload parge and cache
    function MyReload(){
        // location.reload(true)
    }

})();