Additional shortlink

9/13/2024, 2:28:10 PM

目前为 2024-09-23 提交的版本。查看 最新版本

// ==UserScript==
// @name        Additional shortlink
// @namespace   Violentmonkey&Tampermonkey Scripts
// @match       *://*/*
// @grant       none
// @version     1.2
// @author      Ojo Ngono
// @description 9/13/2024, 2:28:10 PM
// ==/UserScript==


(function() {
    'use strict';

    window.addEventListener('load', function() {
        var tombol = document.getElementById('tp-snp2');
        if (tombol) {
            tombol.click();
        }
    });

    function checkAndClickVerify() {
        const timerElement = document.getElementById('myTimer');
        const verifyButton = document.getElementById('VerifyBtn');
        if (timerElement && verifyButton) {
            const timerValue = parseInt(timerElement.textContent, 10);
            if (timerValue === 0) {
                verifyButton.click();
                scrollAndClickNext(); 
            }
        }
    }

    function scrollAndClickNext() {
        setTimeout(() => {
            window.scrollTo(0, document.body.scrollHeight); 
            const nextButton = document.getElementById('NextBtn');
            if (nextButton) {
                nextButton.click(); 
            }
        }, 2000); 
    }

    setInterval(checkAndClickVerify, 1000);

    function clickButton(buttonText) {
        const buttons = document.querySelectorAll('button');
        for (let button of buttons) {
            if (button.textContent.includes(buttonText) && button.style.display !== 'none') {
                button.click();
                console.log(`Clicked: ${buttonText}`);
                return true;
            }
        }
        return false;
    }

    
    function observeDOM() {
        const observer = new MutationObserver(() => {
            if (clickButton('Click Here (Step 1 of 4)')) {
                setTimeout(() => {
                    if (clickButton('Click Here (Step 2 of 4)')) {
                        setTimeout(() => {
                            if (clickButton('Click Here (Step 3 of 4)')) {
                                setTimeout(() => {
                                    if (!clickButton('Continue to Next Page (Step 4)')) {
                                        console.log('Attempting to click "Continue to Next Page (Step 4)"');                                       
                                        setTimeout(() => clickButton('Continue to Next Page (Step 4)'), 5000);
                                    }
                                }, 2000); 
                            }
                        }, 1000); 
                    }
                }, 1000); 
            }
        });

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

    observeDOM();


    window.addEventListener('load', function() {
        const icons = document.querySelectorAll('.stat');
        const iconCount = {};

        icons.forEach(icon => {
            const iconClass = icon.querySelector('i').className;
            if (iconCount[iconClass]) {
                iconCount[iconClass]++;
            } else {
                iconCount[iconClass] = 1;
            }
        });

        let leastDisplayedIcon = null;
        let leastCount = Infinity;

        for (const iconClass in iconCount) {
            if (iconCount[iconClass] < leastCount) {
                leastCount = iconCount[iconClass];
                leastDisplayedIcon = iconClass;
            }
        }

        icons.forEach(icon => {
            if (icon.querySelector('i').className === leastDisplayedIcon) {
                icon.click();

                setTimeout(function() {
                    const confirmButton = document.querySelector('.modal-footer .btn-primary');
                    if (confirmButton) {
                        confirmButton.click();
                    }
                }, 2000);

                return;
            }
        });
    }, false);
})();