Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name VT Reanalyze Auto Click Shadow + Blank + Close
- // @namespace http://tampermonkey.net/
- // @version 1.3
- // @description Auto click VirusTotal Reanalyze, then blank page, then try to close tab
- // @match https://www.virustotal.com/*
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- let clickedUrl = null;
- let closingStarted = false;
- function findInShadow(root) {
- if (!root) return null;
- if (root.querySelector) {
- const el = root.querySelector('a#reanalize');
- if (el) return el;
- }
- const nodes = root.querySelectorAll ? root.querySelectorAll('*') : [];
- for (const node of nodes) {
- if (node.shadowRoot) {
- const found = findInShadow(node.shadowRoot);
- if (found) return found;
- }
- }
- return null;
- }
- function blankThenClose() {
- if (closingStarted) return;
- closingStarted = true;
- console.log('[VT] waiting 5s before blanking tab');
- setTimeout(() => {
- console.log('[VT] going to about:blank');
- location.replace('about:blank');
- setTimeout(() => {
- console.log('[VT] trying to close blank tab');
- window.open('', '_self');
- window.close();
- }, 300);
- }, 10000);
- }
- function clickReanalyze() {
- if (clickedUrl === location.href) return;
- const btn = findInShadow(document);
- if (!btn) {
- console.log('[VT] button not found');
- return;
- }
- try {
- btn.scrollIntoView({ block: 'center' });
- } catch {}
- ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click'].forEach(type => {
- btn.dispatchEvent(new MouseEvent(type, {
- bubbles: true,
- cancelable: true,
- composed: true,
- view: window
- }));
- });
- btn.click();
- clickedUrl = location.href;
- console.log('[VT] clicked');
- blankThenClose();
- }
- setInterval(clickReanalyze, 1000);
- })();
Advertisement
Add Comment
Please, Sign In to add comment