Greasy Fork

Greasy Fork is available in English.

雷速体育移动端显示指数并高亮显示亚盘水位

雷速体育移动端网页显示指数tab,并在亚盘页面高亮显示水位,方便统计各个公司命中率。

当前为 2025-03-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         雷速体育移动端显示指数并高亮显示亚盘水位
// @namespace    http://dol.freevar.com/
// @version      1.0
// @description  雷速体育移动端网页显示指数tab,并在亚盘页面高亮显示水位,方便统计各个公司命中率。
// @author       Dolphin
// @match        https://m.leisu.com/*
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 修改UserAgent
    Object.defineProperty(navigator, 'userAgent', {
        value: '雷速体育/9.5.0 (Android 13; Mobile; com.leisu.sports)',
        configurable: false,
        writable: false
    });

    // 主处理函数
    function processTables() {
        document.querySelectorAll('table').forEach(table => {
            const headers = table.querySelectorAll('th');
            if (headers.length < 3 ||
                headers[0].textContent.trim() !== '公司' ||
                headers[1].textContent.trim() !== '初始') return;

            table.querySelectorAll('tr:not(:first-child)').forEach(tr => {
                const initialTd = tr.querySelectorAll('td')[1];
                if (!initialTd) return;

                const spans = initialTd.querySelectorAll('div.td-box-son > span');
                if (spans.length < 3) return;

                const home = parseFloat(spans[0].textContent);
                const away = parseFloat(spans[2].textContent);

                spans[0].style.backgroundColor = '';
                spans[2].style.backgroundColor = '';

                if (home > away) {
                    spans[0].style.backgroundColor = '#fcc';
                    spans[2].style.backgroundColor = '#cfc';
                } else if (home < away) {
                    spans[0].style.backgroundColor = '#cfc';
                    spans[2].style.backgroundColor = '#fcc';
                }
            });
        });
    }

    // 初始化执行
    window.addEventListener('DOMContentLoaded', () => {
        processTables();

        // 创建观察者监听表格变化
        const observer = new MutationObserver((mutations) => {
            mutations.forEach(mutation => {
                if (mutation.addedNodes.length || mutation.type === 'childList') {
                    processTables();
                }
            });
        });

        // 监听整个文档的变化
        observer.observe(document.body, {
            childList: true,
            subtree: true,
            characterData: true
        });
    });
})();