Greasy Fork 支持简体中文。

Modo juntada de alvará - PROJUDI TJBA

Redireciona para a página de movimentação, mostra advogados, destaca números de processo e exibe parte do número na guia (Projudi TJBA).

// ==UserScript==
// @name         Modo juntada de alvará - PROJUDI TJBA
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Redireciona para a página de movimentação, mostra advogados, destaca números de processo e exibe parte do número na guia (Projudi TJBA).
// @author       Levi
// @match        https://projudi.tjba.jus.br/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- Redirecionar para a página de movimentação ---
    // @author       Levi
    // @version      0.1
    if (window.location.href.includes('projudi/listagens/DadosProcesso')) {
        (function() {
            const urlParams = new URLSearchParams(window.location.search);
            const numeroProcesso = urlParams.get('numeroProcesso');
            const novaURL = `https://projudi.tjba.jus.br/projudi/movimentacao/MovimentarProcesso?numeroProcesso=${numeroProcesso}`;
            window.location.replace(novaURL);
        })();
    }

    // --- Mostrar Advogados automaticamente ---
    // @author       Levi
    // @version      0.4
    (function() {
        var clickedButtons = new Set();

        function clickMostrarOcultar() {
            console.log("Executando clickMostrarOcultar");
            var links = document.querySelectorAll('a[href*="mostraOculta"][href*="\'Adv\'"]');
            console.log("Número de links encontrados:", links.length);

            links.forEach(function(link) {
                var buttonId = link.href;
                if (!clickedButtons.has(buttonId)) {
                    console.log("Clicando em:", link);
                    link.click();
                    clickedButtons.add(buttonId);
                } else {
                    console.log("Botão já clicado:", link);
                }
            });
        }

        clickMostrarOcultar();

        var targetNode = document.querySelector('table.tabelaLista');
        if (targetNode) {
            var observer = new MutationObserver(function(mutations) {
                mutations.forEach(function(mutation) {
                    if (mutation.addedNodes.length > 0) {
                        clickMostrarOcultar();
                    }
                });
            });
            var config = { attributes: true, childList: true, subtree: true };
            observer.observe(targetNode, config);
        }
    })();

    // --- Destacar Processos ---
    // @author       Levi
    // @version      1.5
    (function() {
        function colorirProcesso() {
            function processarTexto(node) {
                const regex = /\b(\d{7}-\d{2}\.\d{4}\.\d\.\d{2}\.\d{4})\b/g;

                if (node.nodeType === 3) {
                    const texto = node.nodeValue;
                    if (regex.test(texto)) {
                        const span = document.createElement('span');
                        span.innerHTML = texto.replace(regex, function(match) {
                            const primeiraParte = match.substring(0, 1);
                            const quatroPrimeiros = match.substring(1, 5);
                            const restoNumero = match.substring(5);
                            return `${primeiraParte}<span style="color: #0000FF; font-size: 1.4em;">${quatroPrimeiros}</span>${restoNumero}`;
                        });
                        node.parentNode.replaceChild(span, node);
                    }
                } else if (node.nodeType === 1 && !['SCRIPT', 'STYLE', 'TEXTAREA'].includes(node.tagName)) {
                    Array.from(node.childNodes).forEach(processarTexto);
                }
            }

            processarTexto(document.body);

            const observer = new MutationObserver((mutations) => {
                mutations.forEach((mutation) => {
                    mutation.addedNodes.forEach((node) => {
                        processarTexto(node);
                    });
                });
            });

            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        }

        if (document.readyState === "loading") {
            document.addEventListener('DOMContentLoaded', colorirProcesso);
        } else {
            colorirProcesso();
        }
    })();

    // --- Número de Processo na Guia ---
    // @author       Levi
    // @version      0.9
    (function() {
        const url = window.location.href;
        if (url.includes('projudi/listagens') || url.includes('projudi/movimentacao')) {
            const processNumberPattern = /\d{7}-\d{2}\.\d{4}\.\d\.\d{2}\.\d{4}/;
            let titleUpdated = false;

            function updateTitleWithProcessNumber() {
                if (titleUpdated) return;

                const bodyText = document.body.innerText;
                const processNumberMatch = bodyText.match(processNumberPattern);
                if (processNumberMatch && processNumberMatch.length > 0) {
                    const processNumber = processNumberMatch[0];
                    const firstFourDigits = processNumber.slice(1, 5);

                    document.title = firstFourDigits;
                    console.log(`Título atualizado: ${firstFourDigits}`);

                    titleUpdated = true;
                    observer.disconnect();
                    clearInterval(intervalId);
                } else {
                    console.log('Número do processo não encontrado.');
                }
            }

            const observer = new MutationObserver(function(mutations) {
                mutations.forEach(function(mutation) {
                    updateTitleWithProcessNumber();
                });
            });

            observer.observe(document.body, { childList: true, subtree: true });

            const intervalId = setInterval(updateTitleWithProcessNumber, 100);
        } else {
            console.log('O script não será executado nesta página.');
        }
    })();
})();

/*
MIT License

Copyright (c) 2023 Levi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/