relacao de bens autocheck

marcar automaticamente a caixa de relação de bens no asiweb

// ==UserScript==
// @name         relacao de bens autocheck
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  marcar automaticamente a caixa de relação de bens no asiweb
// @author       ils94
// @match        https://asiweb.tre-rn.jus.br/asi/web?action=start&target=com.linkdata.corporativo.relatorios.web.AvailableReportsGateway&shadow=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let outerInterval;

    // Function to check the checkbox and input text
    function checkAndInput() {
        console.log('Attempting to find the checkbox and textbox...');

        // Select the checkbox and textbox using their XPath
        var checkboxXPath = "/html/body/div[2]/div[3]/form/div[1]/div[2]/div[2]/table/tbody/tr[50]/td[3]/input";
        var textboxXPath = "/html/body/div[2]/div[3]/form/div[1]/div[2]/div[2]/table/tbody/tr[50]/td[4]/input";

        var checkbox = document.evaluate(checkboxXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        var textbox = document.evaluate(textboxXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

        if (checkbox && textbox) {
            console.log('Checkbox and textbox found. Starting action loop...');
            var actionInterval = setInterval(function() {
                checkbox.checked = true;
                textbox.value = ",";
                console.log('Checkbox checked and comma inputted.');
                if (checkbox.checked && textbox.value === ",") {
                    clearInterval(actionInterval);
                    clearInterval(outerInterval);
                    console.log('Actions completed successfully.');
                }
            }, 500);
        } else {
            console.log('Checkbox or textbox not found. Retrying...');
        }
    }

    // Start the initial loop
    outerInterval = setInterval(checkAndInput, 500);

})();