// ==UserScript== // @name 整蛊小助手 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在网页上随机触发一些无伤大雅的整蛊效果,仅供娱乐 // @author 归鸿 // @match *://*/* // @grant none // @license GPL-3.0 // ==/UserScript== (function() { 'use strict'; // 整蛊效果列表 const pranks = [ // 1. 页面翻转 function() { document.body.style.transition = 'transform 0.8s'; document.body.style.transform = 'rotate(180deg)'; setTimeout(() => { document.body.style.transform = ''; }, 3000); }, // 2. 随机飘落表情雨 function() { const emojis = ['😂', '🤣', '😜', '🤪', '😈', '👻', '🎃', '💩']; for (let i = 0; i < 30; i++) { const emoji = document.createElement('div'); emoji.textContent = emojis[Math.floor(Math.random() * emojis.length)]; emoji.style.position = 'fixed'; emoji.style.left = Math.random() * 100 + 'vw'; emoji.style.top = '-10vh'; emoji.style.fontSize = (20 + Math.random() * 40) + 'px'; emoji.style.pointerEvents = 'none'; emoji.style.zIndex = '99999'; emoji.style.transition = `transform ${2 + Math.random() * 3}s linear`; document.body.appendChild(emoji); requestAnimationFrame(() => { emoji.style.transform = `translateY(${110 + Math.random() * 50}vh) rotate(${Math.random() * 720}deg)`; }); setTimeout(() => emoji.remove(), 5000); } }, // 3. 所有图片随机抖动 function() { const imgs = document.querySelectorAll('img'); imgs.forEach(img => { img.style.transition = 'transform 0.1s'; const interval = setInterval(() => { if (!document.contains(img)) { clearInterval(interval); return; } img.style.transform = `translate(${Math.random() * 10 - 5}px, ${Math.random() * 10 - 5}px) rotate(${Math.random() * 6 - 3}deg)`; }, 100); setTimeout(() => { clearInterval(interval); img.style.transform = ''; }, 3000); }); }, // 4. 假鼠标指针混乱 function() { const fakeCursor = document.createElement('div'); fakeCursor.innerHTML = '🖱️'; fakeCursor.style.position = 'fixed'; fakeCursor.style.fontSize = '30px'; fakeCursor.style.pointerEvents = 'none'; fakeCursor.style.zIndex = '99999'; fakeCursor.style.transition = 'left 0.05s, top 0.05s'; document.body.appendChild(fakeCursor); const realCursor = { x: 0, y: 0 }; document.addEventListener('mousemove', function(e) { realCursor.x = e.clientX; realCursor.y = e.clientY; // 让假光标跟随但有一点偏移和延迟 const offsetX = (Math.random() - 0.5) * 60; const offsetY = (Math.random() - 0.5) * 60; fakeCursor.style.left = (realCursor.x + offsetX) + 'px'; fakeCursor.style.top = (realCursor.y + offsetY) + 'px'; }, { once: false }); setTimeout(() => { fakeCursor.remove(); document.removeEventListener('mousemove', null); }, 5000); }, // 5. 页面元素随机变色 function() { const elements = document.querySelectorAll('*'); const colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff', '#ff8800']; elements.forEach(el => { if (el.style) { const color = colors[Math.floor(Math.random() * colors.length)]; el.style.transition = 'background-color 0.3s, color 0.3s'; el.style.backgroundColor = color; el.style.color = '#ffffff'; } }); setTimeout(() => { elements.forEach(el => { if (el.style) { el.style.backgroundColor = ''; el.style.color = ''; } }); }, 3000); }, // 6. 随机弹出警告框(无害内容) function() { const messages = [ '⚠️ 警告:检测到系统异常!\n(其实是整蛊效果)', '🤖 机器人即将接管您的电脑!\n(开玩笑的)', '🎉 恭喜您中奖了!请点击确定领取!\n(其实啥也没有)', '💀 您的电脑将在5秒后自毁...\n(骗你的啦)' ]; alert(messages[Math.floor(Math.random() * messages.length)]); }, // 7. 所有文字倒序显示 function() { const walker = document.createTreeWalker( document.body, NodeFilter.SHOW_TEXT, { acceptNode: function(node) { if (node.parentElement && ['SCRIPT', 'STYLE', 'NOSCRIPT'].includes(node.parentElement.tagName)) { return NodeFilter.FILTER_REJECT; } return NodeFilter.FILTER_ACCEPT; } } ); const textNodes = []; let node; while (node = walker.nextNode()) { textNodes.push(node); } textNodes.forEach(node => { if (node.textContent.trim()) { node.textContent = node.textContent.split('').reverse().join(''); } }); setTimeout(() => { textNodes.forEach(node => { if (node.textContent.trim()) { node.textContent = node.textContent.split('').reverse().join(''); } }); }, 3000); } ]; // 随机选择一种整蛊效果执行 function executeRandomPrank() { const index = Math.floor(Math.random() * pranks.length); pranks[index](); } // 每隔10-20秒随机触发一次整蛊 function schedulePrank() { const delay = 10000 + Math.random() * 10000; // 10~20秒 setTimeout(() => { executeRandomPrank(); schedulePrank(); // 继续安排下一次 }, delay); } // 开始整蛊(延迟5秒后开始,给用户一点缓冲) setTimeout(() => { schedulePrank(); // 初次执行一次 setTimeout(executeRandomPrank, 2000); }, 5000); // 用户可以通过点击页面任意位置5次来暂时停用整蛊(彩蛋) let clickCount = 0; document.addEventListener('click', function() { clickCount++; if (clickCount >= 5) { alert('整蛊模式已暂停!点击确定后恢复。'); clickCount = 0; // 简单粗暴地重新加载脚本环境(实际是清除所有计时器) // 这里我们重新设置调度 // 注意:由于setTimeout的id无法全局清除,我们采用重置方式 // 这里为了演示,我们只清空当前计时器并重新调度 // 实际使用中,可以用一个全局标志来控制 // 为了简化,我们重置整个脚本的执行环境 location.reload(); // 刷新页面以重置所有效果 } }); console.log('整蛊小助手已启动!点击页面任意位置5次可暂停。'); })();