// ==UserScript== // @name 🫧鼠标指针美化 // @namespace http://gongju.dadiyouhui03.cn/app/tool/youhou/index.html // @version 1.0.0 // @description ✨可自定义鼠标特效等显示效果,兼容大部分网站。自带40多个效果,几百种组合。定义属于你自己的专属鼠标效果。 // @author 伏黑甚而 // @match *://*/* // @grant GM_addStyle // @grant GM_download // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @grant unsafeWindow // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_openInTab // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM.getValue // @grant GM.setValue // @grant GM_info // @grant GM_notification // @run-at document-idle // @icon http://cur.cursors-4u.net/anime/ani-12/ani1136.gif // @noframes // @connect * // @downloadURL https://update.greasyfork.icu/scripts/538573/%F0%9F%AB%A7%E9%BC%A0%E6%A0%87%E6%8C%87%E9%92%88%E7%BE%8E%E5%8C%96.user.js // @updateURL https://update.greasyfork.icu/scripts/538573/%F0%9F%AB%A7%E9%BC%A0%E6%A0%87%E6%8C%87%E9%92%88%E7%BE%8E%E5%8C%96.meta.js // ==/UserScript== (function() { 'use strict'; // 默认配置 const DEFAULT_CONFIG = { enabled: false, cursorNormal: 'https://www.dadiyouhui02.cn/img/menghuan.ico', cursorHover: 'https://ae01.alicdn.com/kf/H88647b1696564b9d880fdf741d728ec3a.png', cursorClick: 'https://ae01.alicdn.com/kf/H88647b1696564b9d880fdf741d728ec3a.png', textEffect: { enabled: false, words: ['❤', '💖', '💝', '💕', '💗'], fontSize: 16, customText: '', useCustomText: false } }; // 预设光标效果 const PRESET_CURSORS = { '梦幻': 'https://www.dadiyouhui02.cn/img/menghuan.ico', '手型': 'https://www.dadiyouhui02.cn/img/shou32x32.ico', '爱心': 'https://ae01.alicdn.com/kf/H88647b1696564b9d880fdf741d728ec3a.png', '游戏1': 'http://cur.cursors-4u.net/games/gam-13/gam1232.png', '游戏2': 'http://cur.cursors-4u.net/games/gam-14/gam1340.cur', '游戏3': 'http://cur.cursors-4u.net/games/gam-14/gam1338.cur', '游戏4': 'http://cur.cursors-4u.net/games/gam-4/gam376.cur', '游戏5': 'http://cur.cursors-4u.net/games/gam-4/gam375.cur', '卡通1': 'http://cur.cursors-4u.net/toons/too-2/too150.cur', '指针1': 'http://cur.cursors-4u.net/cursors/cur-7/cur641.cur', '指针2': 'http://cur.cursors-4u.net/cursors/cur-2/cur119.cur', '指针3': 'http://cur.cursors-4u.net/cursors/cur-2/cur116.cur', '指针4': 'http://cur.cursors-4u.net/cursors/cur-9/cur805.png', '指针5': 'http://cur.cursors-4u.net/cursors/cur-9/cur812.png', '指针6': 'http://cur.cursors-4u.net/cursors/cur-3/cur273.cur', '其他1': 'http://cur.cursors-4u.net/others/oth-4/oth305.cur', '动画1': 'http://ani.cursors-4u.net/cursors/cur-11/cur1089.cur', '表情1': 'http://cur.cursors-4u.net/smilies/smi-3/smi267.png', '动漫1': 'http://ani.cursors-4u.net/anime/ani-13/ani1227.cur', '动漫2': 'http://cur.cursors-4u.net/anime/ani-9/ani878.png', '动漫3': 'http://cur.cursors-4u.net/anime/ani-12/ani1112.png', '动漫4': 'http://cur.cursors-4u.net/anime/ani-1/ani195.png', '动漫5': 'http://cur.cursors-4u.net/anime/ani-12/ani1136.gif', '自然1': 'http://cur.cursors-4u.net/nature/nat-11/nat1034.gif', '自然2': 'http://cur.cursors-4u.net/nature/nat-11/nat1028.gif', '自然3': 'http://cur.cursors-4u.net/nature/nat-11/nat1033.gif', '特殊1': 'http://cur.cursors-4u.net/special/spe-3/spe302.png', '符号1': 'http://cur.cursors-4u.net/symbols/sym-6/sym501.png', '指针7': 'http://cur.cursors-4u.net/cursors/cur-2/cur125.cur', '符号2': 'http://cur.cursors-4u.net/symbols/sym-7/sym646.gif', '指针8': 'http://cur.cursors-4u.net/cursors/cur-3/cur221.png', '指针9': 'http://cur.cursors-4u.net/cursors/cur-9/cur265.cur', '其他3': 'http://cur.cursors-4u.net/others/oth-8/oth755.cur', '特殊2': 'http://cur.cursors-4u.net/special/spe-2/spe114.cur', '其他4': 'http://cur.cursors-4u.net/others/oth-8/oth726.png', '指针10': 'http://cur.cursors-4u.net/cursors/cur-8/cur740.png', '指针11': 'http://cur.cursors-4u.net/cursors/cur-8/cur727.png', '指针12': 'http://cur.cursors-4u.net/cursors/cur-8/cur728.png', '指针13': 'http://cur.cursors-4u.net/cursors/cur-11/cur1054.cur', '游戏6': 'http://cur.cursors-4u.net/games/gam-14/gam1391.png' }; // 预设文字效果 const PRESET_TEXTS = { '爱心': ['❤', '💖', '💝', '💕', '💗'], '星星': ['⭐', '🌟', '✨', '💫', '⭐'], '笑脸': ['😊', '😄', '😃', '😁', '😆'], '动物': ['🐱', '🐶', '🐼', '🐨', '🦊'], '水果': ['🍎', '🍊', '🍇', '🍉'], '符号': ['✿', '❀', '❁', '✾', '❃'], '箭头': ['➜', '➤', '➳', '➵', '➸'], '花朵': ['🌸', '🌺', '🌹', '🌷', '🌼'], '天气': ['☀️', '🌈', '❄️', '⚡', '🌙'], '食物': ['🍕', '🍔', '🍟', '🍦', '🍩'], '运动': ['⚽', '🏀', '🎾', '🏈', '⚾'], '音乐': ['🎵', '🎶', '🎸', '🎹', '🎺'], '游戏': ['🎮', '🎲', '🎯', '🎳', '🎰'], '节日': ['🎄', '🎃', '🎁', '🎊', '🎉'], '自然': ['🌿', '🍃', '🌱', '🌺', '🌸'] }; // 初始化配置 function initializeConfig() { if (!GM_getValue('config')) { GM_setValue('config', DEFAULT_CONFIG); } } // 获取配置 function getConfig() { return GM_getValue('config') || DEFAULT_CONFIG; } // 保存配置 function saveConfig(config) { GM_setValue('config', config); } // 创建配置弹窗 function createConfigModal() { const config = getConfig(); // 创建模态框样式 const style = ` .cursor-config-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #1e1e1e; padding: 20px; border-radius: 10px; box-shadow: 0 0 20px rgba(0,0,0,0.5); z-index: 999999; min-width: 500px; max-width: 90vw; max-height: 90vh; overflow-y: auto; font-family: Arial, sans-serif; color: #fff; } .cursor-config-modal h2 { margin: 0 0 20px 0; color: #cccccc; text-align: center; font-size: 1.5em; text-shadow: 0 0 10px rgba(204, 204, 204, 0.3); } .cursor-config-modal .qr-code-container { text-align: center; margin-bottom: 20px; padding: 10px; background: #2d2d2d; border-radius: 8px; border: 1px solid #444; } .cursor-config-modal .qr-code { display: inline-block; border-radius: 4px; margin-bottom: 10px; } .cursor-config-modal .qr-code-text { color: #cccccc; font-size: 14px; line-height: 1.5; text-shadow: 0 0 5px rgba(204, 204, 204, 0.2); font-weight: bold; } .cursor-config-modal .section { margin-bottom: 20px; background: #2d2d2d; padding: 15px; border-radius: 8px; border: 1px solid #444; } .cursor-config-modal .section-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 5px; border-radius: 4px; } .cursor-config-modal .section-header:hover { background: #444; } .cursor-config-modal .section-title { font-weight: bold; color: #4CAF50; font-size: 1.1em; text-shadow: 0 0 5px rgba(76, 175, 80, 0.2); } .cursor-config-modal .section-content { margin-top: 10px; padding-top: 10px; border-top: 1px solid #444; transition: all 0.3s ease; max-height: 1000px; overflow: hidden; } .cursor-config-modal .section-content.collapsed { margin-top: 0; padding-top: 0; max-height: 0; border-top: none; } .cursor-config-modal .toggle-icon { color: #4CAF50; font-size: 1.2em; transition: transform 0.3s ease; } .cursor-config-modal .toggle-icon.collapsed { transform: rotate(-90deg); } .cursor-config-modal select, .cursor-config-modal input[type="text"] { width: 100%; padding: 8px; margin: 5px 0; border: 1px solid #444; border-radius: 4px; background: #333; color: #fff; font-size: 14px; } .cursor-config-modal .custom-url-input { display: flex; gap: 10px; margin: 10px 0; } .cursor-config-modal .custom-url-input input { flex-grow: 1; } .cursor-config-modal .custom-url-input button { padding: 8px 15px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background 0.3s ease; } .cursor-config-modal .custom-url-input button:hover { background: #45a049; } .cursor-config-modal .button-group { text-align: center; margin-top: 20px; } .cursor-config-modal button { padding: 8px 20px; margin: 0 10px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: all 0.3s ease; font-size: 14px; } .cursor-config-modal .save-btn { background: #4CAF50; color: white; } .cursor-config-modal .save-btn:hover { background: #45a049; transform: translateY(-2px); } .cursor-config-modal .cancel-btn { background: #f44336; color: white; } .cursor-config-modal .cancel-btn:hover { background: #da190b; transform: translateY(-2px); } .cursor-config-modal .preview { margin: 10px 0; padding: 10px; border: 1px solid #444; border-radius: 4px; text-align: center; background: #333; min-height: 50px; display: flex; align-items: center; justify-content: center; } .cursor-config-modal .preview-text { font-size: 24px; line-height: 1.5; } .cursor-config-modal .overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 999998; } .cursor-config-modal label { display: block; margin: 10px 0; color: #e0e0e0; font-size: 14px; } .cursor-config-modal input[type="checkbox"] { margin-right: 8px; width: 16px; height: 16px; } .cursor-config-modal select:focus, .cursor-config-modal input:focus { outline: none; border-color: #4CAF50; box-shadow: 0 0 5px rgba(76, 175, 80, 0.3); } .cursor-config-modal .modal-content { position: relative; z-index: 999999; } .cursor-config-modal .preview-area { cursor: pointer; padding: 20px; text-align: center; background: #333; border-radius: 4px; margin: 10px 0; } .cursor-config-modal .preview-area:hover { background: #444; } .cursor-config-modal .cursor-option { display: flex; align-items: center; padding: 5px; margin: 2px 0; border-radius: 4px; cursor: pointer; } .cursor-config-modal .cursor-option:hover { background: #444; } .cursor-config-modal .cursor-option[data-selected="true"] { background: #4CAF50; } .cursor-config-modal .cursor-preview { width: 32px; height: 32px; margin-right: 10px; object-fit: contain; } .cursor-config-modal .cursor-name { flex-grow: 1; } .cursor-config-modal .cursor-list { max-height: 300px; overflow-y: auto; margin: 10px 0; padding: 5px; background: #333; border-radius: 4px; } `; GM_addStyle(style); // 创建模态框HTML const modal = document.createElement('div'); modal.className = 'cursor-config-modal'; modal.innerHTML = `
`; // 添加预览功能 function updatePreview(elementId, cursorUrl) { const element = modal.querySelector(`#${elementId}`); if (element) { element.style.cursor = `url('${cursorUrl}'), auto`; } } // 更新文字特效预览 function updateTextPreview() { const textEffect = modal.querySelector('#textEffect'); const preview = modal.querySelector('#textEffectPreview'); const useCustomText = modal.querySelector('#useCustomText'); const customText = modal.querySelector('#customText'); const fontSize = modal.querySelector('#fontSize'); if (preview) { if (useCustomText.checked) { const customWords = customText.value.split(',').map(word => word.trim()).filter(word => word); preview.textContent = customWords.join(' '); textEffect.disabled = true; } else { preview.textContent = textEffect.value.split(',').join(' '); textEffect.disabled = false; } preview.style.fontSize = `${fontSize.value}px`; } } // 处理光标选择 function handleCursorSelection(listId, previewId) { const list = modal.querySelector(`#${listId}`); const options = list.querySelectorAll('.cursor-option'); options.forEach(option => { option.addEventListener('click', () => { // 移除其他选项的选中状态 options.forEach(opt => opt.removeAttribute('data-selected')); // 设置当前选项为选中状态 option.setAttribute('data-selected', 'true'); // 更新预览 updatePreview(previewId, option.dataset.url); }); }); } // 添加自定义光标 function addCustomCursor(inputId, listId, previewId) { const input = modal.querySelector(`#${inputId}`); const list = modal.querySelector(`#${listId}`); const url = input.value.trim(); if (url) { const option = document.createElement('div'); option.className = 'cursor-option'; option.dataset.url = url; option.innerHTML = ` 自定义光标 自定义光标 `; // 添加点击事件 option.addEventListener('click', () => { const options = list.querySelectorAll('.cursor-option'); options.forEach(opt => opt.removeAttribute('data-selected')); option.setAttribute('data-selected', 'true'); updatePreview(previewId, url); }); list.insertBefore(option, list.firstChild); input.value = ''; // 自动选中新添加的光标 option.click(); } } // 处理展开/收缩 function handleSectionToggle() { const headers = modal.querySelectorAll('.section-header'); headers.forEach(header => { header.addEventListener('click', () => { const sectionId = header.dataset.section; const content = modal.querySelector(`#${sectionId}Content`); const icon = header.querySelector('.toggle-icon'); content.classList.toggle('collapsed'); icon.classList.toggle('collapsed'); }); }); } // 初始化光标选择 handleCursorSelection('normalCursorList', 'normalCursorPreview'); handleCursorSelection('hoverCursorList', 'hoverCursorPreview'); handleCursorSelection('clickCursorList', 'clickCursorPreview'); // 初始化展开/收缩 handleSectionToggle(); // 添加自定义光标事件 modal.querySelector('#addNormalCustom').addEventListener('click', () => { addCustomCursor('normalCustomUrl', 'normalCursorList', 'normalCursorPreview'); }); modal.querySelector('#addHoverCustom').addEventListener('click', () => { addCustomCursor('hoverCustomUrl', 'hoverCursorList', 'hoverCursorPreview'); }); modal.querySelector('#addClickCustom').addEventListener('click', () => { addCustomCursor('clickCustomUrl', 'clickCursorList', 'clickCursorPreview'); }); // 添加事件监听器 modal.querySelector('#useCustomText').addEventListener('change', updateTextPreview); modal.querySelector('#customText').addEventListener('input', updateTextPreview); modal.querySelector('#fontSize').addEventListener('input', updateTextPreview); modal.querySelector('#textEffect').addEventListener('change', updateTextPreview); // 初始化预览 const selectedNormal = modal.querySelector('#normalCursorList [data-selected="true"]'); const selectedHover = modal.querySelector('#hoverCursorList [data-selected="true"]'); const selectedClick = modal.querySelector('#clickCursorList [data-selected="true"]'); if (selectedNormal) updatePreview('normalCursorPreview', selectedNormal.dataset.url); if (selectedHover) updatePreview('hoverCursorPreview', selectedHover.dataset.url); if (selectedClick) updatePreview('clickCursorPreview', selectedClick.dataset.url); updateTextPreview(); // 保存配置 modal.querySelector('#saveConfig').addEventListener('click', () => { const newConfig = { enabled: modal.querySelector('#enableEffect').checked, cursorNormal: modal.querySelector('#normalCursorList [data-selected="true"]').dataset.url, cursorHover: modal.querySelector('#hoverCursorList [data-selected="true"]').dataset.url, cursorClick: modal.querySelector('#clickCursorList [data-selected="true"]').dataset.url, textEffect: { enabled: modal.querySelector('#enableTextEffect').checked, words: modal.querySelector('#textEffect').value.split(','), fontSize: modal.querySelector('#fontSize').value, customText: modal.querySelector('#customText').value, useCustomText: modal.querySelector('#useCustomText').checked } }; saveConfig(newConfig); modal.remove(); GM_notification({ text: '设置已保存', title: '鼠标美化', timeout: 2000 }); location.reload(); }); modal.querySelector('#cancelConfig').addEventListener('click', () => { modal.remove(); }); // 阻止点击模态框内容时关闭 modal.querySelector('.modal-content').addEventListener('click', (e) => { e.stopPropagation(); }); // 点击遮罩层关闭 modal.querySelector('.overlay').addEventListener('click', () => { modal.remove(); }); document.body.appendChild(modal); } // 应用鼠标样式 function applyCursorStyles() { const config = getConfig(); if (!config.enabled) return; const style = ` html, body { cursor: url('${config.cursorNormal}'), default !important; } input[type=button], button, a:hover { cursor: url('${config.cursorHover}'), pointer !important; } `; GM_addStyle(style); // 点击效果 document.addEventListener('click', function(event) { const clickStyle = document.createElement('style'); clickStyle.textContent = `html, body { cursor: url('${config.cursorClick}'), auto !important; }`; document.head.appendChild(clickStyle); setTimeout(() => { clickStyle.remove(); }, 100); }); } // 文字特效 function applyTextEffect() { const config = getConfig(); if (!config.enabled || !config.textEffect.enabled) return; let wordIndex = 0; document.addEventListener('click', function(event) { let text; if (config.textEffect.useCustomText) { const customWords = config.textEffect.customText.split(',').map(word => word.trim()).filter(word => word); if (customWords.length > 0) { text = customWords[wordIndex % customWords.length]; wordIndex = (wordIndex + 1) % customWords.length; } else { text = '❤'; // 默认值 } } else { text = config.textEffect.words[wordIndex]; wordIndex = (wordIndex + 1) % config.textEffect.words.length; } const element = document.createElement('b'); element.textContent = text; element.style.cssText = ` position: fixed; z-index: 999999; pointer-events: none; user-select: none; left: ${event.clientX}px; top: ${event.clientY}px; color: ${getRandomColor()}; font-size: ${config.textEffect.fontSize}px; opacity: 1; transition: all 0.5s ease-out; `; document.body.appendChild(element); setTimeout(() => { element.style.transform = 'translateY(-20px) scale(1.2)'; element.style.opacity = '0'; setTimeout(() => element.remove(), 500); }, 10); }); } // 随机颜色 function getRandomColor() { return `rgb(${Math.floor(Math.random() * 255)}, ${Math.floor(Math.random() * 255)}, ${Math.floor(Math.random() * 255)})`; } // 设置菜单 function setupMenu() { GM_registerMenuCommand('🤓设置鼠标效果', createConfigModal); } // 主函数 function main() { initializeConfig(); setupMenu(); applyCursorStyles(); applyTextEffect(); } // 启动脚本 if (window.top === window.self) { main(); } })();