// ==UserScript== // @name fruit_slice 自定义分数(仅在fruit_slice.php显示) // @namespace http://tampermonkey.net/ // @version 3.0 // @description 只在fruit_slice.php页面显示悬浮窗,自定义提交分数 // @author assistant // @match *://718zf.xyz/fruit_slice.php // @match *://718zf.xyz/fruit_slice_api.php // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; // 自定义分数 window.CUSTOM_SCORE = '100'; // 只在 fruit_slice.php 显示面板 if (location.pathname === '/fruit_slice.php') { function createPanel() { const panel = document.createElement('div'); panel.style.position = 'fixed'; panel.style.top = '20px'; panel.style.right = '20px'; panel.style.padding = '10px 15px'; panel.style.background = '#fff'; panel.style.border = '1px solid #ccc'; panel.style.borderRadius = '8px'; panel.style.zIndex = '999999'; panel.style.boxShadow = '0 0 10px rgba(0,0,0,0.3)'; panel.style.display = 'flex'; panel.style.gap = '8px'; panel.style.alignItems = 'center'; const label = document.createElement('span'); label.textContent = '分数:'; label.style.fontSize = '14px'; const input = document.createElement('input'); input.type = 'number'; input.value = window.CUSTOM_SCORE; input.style.padding = '4px 8px'; input.style.width = '80px'; input.addEventListener('input', () => { window.CUSTOM_SCORE = input.value.trim(); }); panel.appendChild(label); panel.appendChild(input); document.body.appendChild(panel); } window.addEventListener('DOMContentLoaded', createPanel); } // 拦截提交分数请求 const origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url) { this._url = url; origOpen.apply(this, arguments); }; const origSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(data) { if (this._url && this._url.includes('fruit_slice_api.php')) { const score = window.CUSTOM_SCORE || '100'; if (data instanceof FormData) { data.set('score', score); } else if (typeof data === 'string' && data.includes('score=')) { data = data.replace(/score=\d+/g, `score=${score}`); } } origSend.call(this, data); }; })();