Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Auto-Crunchy
- // @description Automatically clicks play/skip when it appears
- // @version 1.0
- // @author Froschi
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- // Change texts to your language
- const TARGET_TEXTS = [
- "SKIP OPENING",
- "OPENING ÜBERSPRINGEN",
- "SKIP INTRO",
- "ÜBERSPRINGEN",
- "CREDITS ÜBERSPRINGEN"
- ];
- let isCooldown = false;
- function getOwnText(el) {
- return Array.from(el.childNodes)
- .filter(node => node.nodeType === Node.TEXT_NODE)
- .map(node => node.textContent.trim())
- .join(" ");
- }
- function tryClickSkipText() {
- const allElements = document.querySelectorAll("*");
- for (const el of allElements) {
- const ownText = getOwnText(el);
- if (!TARGET_TEXTS.includes(ownText)) continue;
- const parent = el.parentElement;
- if (!parent) continue;
- console.log(`💫 Found "${ownText}" button, clicking!`);
- parent.click();
- return true;
- }
- return false;
- }
- function tryClickPlayButton() {
- const playButton = document.querySelector('[data-testid="vilos-large_play_pause_button"][data-test-state="paused"]');
- if (!playButton) return false;
- console.log("▶️ Found paused play button, clicking!");
- playButton.click();
- return true;
- }
- const observer = new MutationObserver(() => {
- if (isCooldown) return;
- if (!tryClickSkipText() && !tryClickPlayButton()) return;
- isCooldown = true;
- console.log("🕒 Cooldown started (10s)~");
- setTimeout(() => {
- isCooldown = false;
- console.log("✅ Cooldown over, watching again~");
- }, 10000);
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- console.log("Watching for skip and play buttons.");
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement