// ==UserScript== // @name Auto Scroll Then Find Element (Background) // @namespace https://viayoo.com/1ol4kj // @version 11.0 // @description Scroll dulu sampai selesai, baru cari element (background) // @author You // @run-at document-end // @match https://*/* // @grant none // ==/UserScript== (function() { 'use strict'; const TARGET_ID = "master-1"; let phase = 'scrolling-down'; let scrollInterval = null; let lastScrollPos = 0; let sameScrollCount = 0; let foundElement = null; // Fungsi cari element function findElement() { console.log(`🔍 Mencari element dengan ID: ${TARGET_ID}`); // Method 1: getElementById let element = document.getElementById(TARGET_ID); if (element) { console.log("✅ Element ditemukan dengan getElementById:", element); return element; } // Method 2: querySelector element = document.querySelector(`#${TARGET_ID}`); if (element) { console.log("✅ Element ditemukan dengan querySelector:", element); return element; } // Method 3: XPath const xpath = `//*[@id="${TARGET_ID}"]`; element = document.evaluate( xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (element) { console.log("✅ Element ditemukan dengan XPath:", element); return element; } console.log("❌ Element tidak ditemukan"); return null; } // Highlight element function highlightElement(element) { element.style.border = '5px solid #00FF00'; element.style.boxShadow = '0 0 40px #00FF00, inset 0 0 20px rgba(0,255,0,0.3)'; element.style.outline = '3px dashed #FFFF00'; element.style.backgroundColor = 'rgba(255, 255, 0, 0.2)'; element.style.position = 'relative'; element.style.zIndex = '999998'; // Highlight parent if (element.parentElement) { element.parentElement.style.border = '3px solid #00BFFF'; element.parentElement.style.backgroundColor = 'rgba(0, 191, 255, 0.1)'; } // Scroll ke element element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }); console.log("✅ Element highlighted"); console.log("Element info:", { tag: element.tagName, id: element.id, class: element.className }); } function stopScrolling(message) { if (scrollInterval) { clearInterval(scrollInterval); scrollInterval = null; } console.log(message); } // Search element after scrolling complete function searchElement() { console.log("=".repeat(50)); console.log("🔍 MULAI MENCARI ELEMENT"); console.log("=".repeat(50)); foundElement = findElement(); if (foundElement) { console.log("🎉 SUKSES! Element ditemukan dan di-highlight"); highlightElement(foundElement); } else { console.log("❌ GAGAL! Element tidak ditemukan di halaman"); console.log(`💡 Pastikan element dengan ID '${TARGET_ID}' ada di halaman`); } } // Main scroll function function autoScroll() { const currentPos = window.scrollY; if (phase === 'scrolling-down') { console.log(`⬇️ Scroll Down: ${Math.round(currentPos)}px`); window.scrollBy(0, 12); if (Math.abs(currentPos - lastScrollPos) < 1) { sameScrollCount++; } else { sameScrollCount = 0; } // Sudah sampai bawah if (sameScrollCount > 20) { phase = 'scrolling-up'; sameScrollCount = 0; console.log("=".repeat(50)); console.log("✅ SAMPAI BAWAH - Mulai scroll ke atas"); console.log("=".repeat(50)); } lastScrollPos = currentPos; } else if (phase === 'scrolling-up') { console.log(`⬆️ Scroll Up: ${Math.round(currentPos)}px`); // Lanjut scroll up window.scrollBy(0, -8); // Cek kalau sudah di atas if (currentPos < 50) { console.log("=".repeat(50)); console.log("✅ SAMPAI ATAS - Proses scroll selesai!"); console.log("=".repeat(50)); stopScrolling('✅ Scroll selesai'); // Tunggu sebentar lalu cari element setTimeout(() => { searchElement(); }, 1000); } } } // START console.log("=".repeat(50)); console.log("🚀 SCRIPT AUTO SCROLL + FIND ELEMENT"); console.log("=".repeat(50)); console.log(`🎯 Target Element: #${TARGET_ID}`); console.log(`📋 XPath: //*[@id="${TARGET_ID}"]`); console.log("📝 Urutan:"); console.log(" 1. Scroll ke bawah sampai habis"); console.log(" 2. Scroll ke atas sampai habis"); console.log(" 3. Cari element dan highlight"); console.log("=".repeat(50)); console.log('⏰ Mulai dalam 2 detik...'); setTimeout(() => { console.log("▶️ START! Mulai scrolling..."); scrollInterval = setInterval(autoScroll, 25); }, 2000); })();