Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name verify
- // @namespace http://tampermonkey.net/
- // @version 2024-01-25
- // @description try to take over the world!
- // @author You
- // @match https://stumblechat.com/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=stumblechat.com
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- class VerifyScript {
- constructor() {
- this.observeDOM();
- this.setupConsoleOverlay();
- }
- clickVerifyButton = (verifyButton) => {
- this.logToOverlay('Attempting to click VERIFY button...');
- if (verifyButton) {
- this.logToOverlay('VERIFY button found.');
- // Remove any existing event listeners on the button
- verifyButton.removeEventListener('click', this.clickVerifyButton);
- // Manually create and dispatch a click event
- const clickEvent = new MouseEvent('click', {
- bubbles: true,
- cancelable: true,
- view: window
- });
- this.logToOverlay('Before dispatchEvent');
- verifyButton.dispatchEvent(clickEvent);
- this.logToOverlay('After dispatchEvent');
- } else {
- this.logToOverlay('VERIFY button not found.');
- }
- }
- observeDOM = () => {
- this.logToOverlay('Setting up MutationObserver...');
- const observer = new MutationObserver((mutationsList) => {
- this.logToOverlay(`Mutation observed... ${mutationsList.length} mutation(s) in total.`);
- for (const mutation of mutationsList) {
- this.logToOverlay(`Mutation type: ${mutation.type}`);
- this.logToOverlay(`Mutation target: ${mutation.target.outerHTML}`);
- this.logToOverlay(`Added nodes: ${mutation.addedNodes.length}`);
- mutation.addedNodes.forEach((node) => {
- if (node instanceof HTMLElement) {
- this.logToOverlay(`Added node: ${node.nodeName}`);
- // Check if the added node is the VERIFY button
- if (node.id === 'interact') {
- // Add a slight delay to ensure modal visibility
- setTimeout(() => {
- // If so, click the button without scrolling
- this.clickVerifyButton(node);
- // Attempt other ways to click the button
- document.querySelector('#modal #interact').click(); // First attempt
- document.querySelector('#modal button#interact').click(); // Second attempt
- }, 500); // Adjust the delay as needed
- }
- }
- });
- this.logToOverlay(`Removed nodes: ${mutation.removedNodes.length}`);
- mutation.removedNodes.forEach((node) => {
- this.logToOverlay(`Removed node: ${node.nodeName}`);
- });
- }
- });
- // Start observing changes in the sc-modal element
- this.logToOverlay('Attempting to observe sc-modal element...');
- const scModal = document.querySelector('#modal');
- if (scModal) {
- this.logToOverlay('sc-modal element found. Starting observation...');
- observer.observe(scModal, { childList: true, subtree: true });
- } else {
- this.logToOverlay('sc-modal element not found.');
- }
- }
- setupConsoleOverlay = () => {
- const consoleOverlay = document.createElement('div');
- consoleOverlay.setAttribute('id', 'console-overlay');
- consoleOverlay.style.position = 'fixed';
- consoleOverlay.style.top = '10px';
- consoleOverlay.style.left = '10px';
- consoleOverlay.style.backgroundColor = 'rgba(255, 255, 255, 0.9)';
- consoleOverlay.style.padding = '10px';
- consoleOverlay.style.border = '1px solid #ccc';
- consoleOverlay.style.zIndex = '9999';
- document.body.appendChild(consoleOverlay);
- this.consoleOverlay = consoleOverlay;
- }
- logToOverlay = (message) => {
- const logEntry = document.createElement('div');
- logEntry.textContent = message;
- if (this.consoleOverlay) {
- this.consoleOverlay.appendChild(logEntry);
- }
- console.log(message);
- }
- }
- // Start the script
- new VerifyScript();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement