发个脚本哈

五级用户 panndora 19天前 1071

// ==UserScript==
// @name         智能彩虹文本转换器Pro
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  实时中文彩虹色转换工具,带右下角浮动控制面板
// @author       Panndora
// @match        *://bbs.oldmantvg.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // HSL转RGB函数
    function hslToRgb(h, s, l) {
        s /= 100;
        l /= 100;
        const k = n => (n + h/30) % 12;
        const a = s * Math.min(l, 1 - l);
        const f = n => l - a * Math.max(-1, Math.min(k(n)-3, 9-k(n), 1));
        return {
            r: Math.round(255 * f(0)),
            g: Math.round(255 * f(8)),
            b: Math.round(255 * f(4))
        };
    }

    // RGB转HEX函数
    function rgbToHex(r, g, b) {
        return "#" + [r,g,b].map(x => {
            const hex = x.toString(16);
            return hex.length === 1 ? "0" + hex : hex;
        }).join("");
    }

    // 生成彩虹色系(36色深色系)
    function generateRainbowColors() {
        const colorSegments = [
            { start: 0, end: 30, count: 3 },    // 红→橙
            { start: 30, end: 60, count: 3 },   // 橙→黄
            { start: 60, end: 120, count: 6 },  // 黄→绿
            { start: 120, end: 240, count: 12 },// 绿→蓝
            { start: 240, end: 270, count: 3 }, // 蓝→靛
            { start: 270, end: 300, count: 3 }, // 靛→紫
            { start: 300, end: 360, count: 6 }  // 紫→红
        ];

        const colors = [];
        colorSegments.forEach(segment => {
            const {start, end, count} = segment;
            const step = (end - start)/(count - 1);
            for(let i = 0; i < count; i++) {
                let hue = start + step * i;
                hue = hue >= 360 ? hue - 360 : hue;
                const rgb = hslToRgb(hue, 100, 40);
                colors.push(rgbToHex(rgb.r, rgb.g, rgb.b));
            }
        });
        return colors;
    }

    const rainbowColors = generateRainbowColors();

    // 创建样式
    const style = document.createElement('style');
    style.textContent = `
        #colorConverter {
            position: fixed;
            bottom: 80px;
            right: 20px;
            background: white;
            border: 1px solid #ccc;
            padding: 20px;
            z-index: 10000;
            width: 250px;
            font-family: 'Microsoft YaHei';
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            display: none;
            max-height: 80vh;
            overflow-y: auto;
        }

        #triggerBtn {
        border: 0;
        background-color: #090;
        color: #fff;
        cursor: pointer;
        height: 38px;
        padding: 5px;
        float: right;
        margin-right: 10px;
        text-align: right;
        display: inline-block;
        }

        #inputText {
            width: 100%;
            height: 100px;
            margin: 10px 0;
            resize: vertical;
        }
        #copyButton {
            padding: 8px 16px;
            background: #2196F3;
            color: white;
            border: none;
            cursor: pointer;
            margin-top: 10px;
        }
        #outputPreview {
            width: 100%;
            min-height: 150px;
            border: 1px solid #eee;
            padding: 10px;
            margin-top: 10px;
            white-space: pre-wrap;
            word-wrap: break-word;
            overflow-y: auto;
            max-height: 300px;
        }
        .button-group { margin: 10px 0; }
    `;
    document.head.appendChild(style);

    // 创建触发按钮
    const triggerBtn = document.createElement('button');
    triggerBtn.id = 'triggerBtn';
    triggerBtn.textContent = '彩虹字体';
    //document.body.appendChild(triggerBtn);
    const targetContainer = document.querySelector('.Tp1');
     if (targetContainer) {
         targetContainer.insertBefore(triggerBtn, targetContainer.firstChild);
        triggerBtn.style.marginRight = '10px'; // 与提交按钮保持间距
    }

    // 创建转换窗口
    const converter = document.createElement('div');
    converter.id = 'colorConverter';
    converter.innerHTML = `
        <h4 style="margin:0 0 15px">老男人彩虹字转换器
            <button id="closeBtn" style="float:right; background:none; border:none; cursor:pointer; font-size:1.2em">×</button>
        </h4>
        <textarea id="inputText" placeholder="输入中文/英文/符号,实时预览彩虹效果..."></textarea>
        <div id="outputPreview"></div>
        <button id="copyButton">复制转换后的彩虹字</button>
    `;
    document.body.appendChild(converter);

    // 实时转换函数
    function convertText() {
        const input = document.getElementById('inputText').value;
        let html = '';
        const colorCount = rainbowColors.length;
        let charCount = 0;

        for (const char of input) {
            const cycle = Math.floor(charCount / colorCount);
            const index = charCount % colorCount;
            const colorIndex = (cycle % 2 === 0) ? index : (colorCount - 1 - index);
            html += `<span style="color:${rainbowColors[colorIndex]}">${char}</span>`;
            charCount++;
        }

        document.getElementById('outputPreview').innerHTML = html;
    }

    // 复制到剪贴板
    // 复制到剪贴板(核心修改部分)
    async function copyToClipboard() {
        const output = document.getElementById('outputPreview');
        const htmlContent = output.innerHTML;
        try {
            // 创建包含HTML内容的Blob
            const blob = new Blob([htmlContent], { type: 'text/html' });
            const clipboardItem = new ClipboardItem({
                'text/html': blob,
                'text/plain': new Blob([output.textContent], { type: 'text/plain' })
            });
            // 写入剪贴板
            await navigator.clipboard.write([clipboardItem]);
            改我('彩虹字已成功复制到剪贴板!');
        } catch (err) {
            // 回退方案:纯文本复制
            try {
                await navigator.clipboard.writeText(htmlContent);
                改我('已复制纯文本格式的HTML代码(部分应用可能不支持富文本粘贴)');
            } catch (err) {
                改我('复制失败,请手动选择内容后复制');
                output.focus();
            }
        }
    }

    // 显示/隐藏逻辑
    document.getElementById('triggerBtn').addEventListener('click', () => {
        converter.style.display = 'block';
        triggerBtn.style.display = 'none';
    });

    document.getElementById('closeBtn').addEventListener('click', () => {
        converter.style.display = 'none';
        triggerBtn.style.display = 'block';
    });

    // 绑定实时转换
    document.getElementById('inputText').addEventListener('input', convertText);

    // 绑定复制事件
    document.getElementById('copyButton').addEventListener('click', copyToClipboard);
})();


使.,,,., AI .Q,, html .


1.png

用之前改一下这个地方.


2.jpg


上一篇:老男人聊“税” 不如聊“睡” ~
下一篇:今天反弹又卖了不少,被同事骂了
最新回复 (13)
  • 四级用户 mrchangkun 19天前
    2 2
    看多了吐系列。
  • 五级用户 panndora 19天前
    0 3


  • 四级用户 Siale 19天前
    0 4
    眼睛吃不消啊~
  • 三级用户 gundam_srx 19天前
    1 5
    在线荷官的感觉
  • 五级用户 乱月 19天前
    1 6

  • 三级用户 jianghan0303 19天前
    0 7
    彩虹大佬
  • 六级用户 colorcat 19天前
    0 8
    。。。。。。论坛为什么突然流行这个了
  • 五级用户 封初然 19天前
    0 9

     

  • 五级用户 掌机游戏爱好者 19天前
    0 10
    colorcat 。。。。。。论坛为什么突然流行这个了
    回复8楼: 我的锅😭
  • 五级用户 掌机游戏爱好者 19天前
    0 11
    mrchangkun 看多了吐系列。
    回复2楼: 你别说,还真的是
  • 四级用户 minghan0313 19天前
    0 12
    哈哈哈,厉害厉害。
  • 六级用户 坚定青蛙 19天前
    0 13
    眼瞎了
  • 六级用户 colorcat 19天前
    0 14
    掌机游戏爱好者 回复8楼: 我的锅😭
    拉出去~突突突突突突~~~~~~😆😆😆😆😆😎😎😎😎😎
    • 老男人游戏网配套论坛
      15
        立即登录 立即注册
发新帖
本论坛禁止发布SWITCH和PS4相关资源,若有其他侵权内容,请致邮3360342659#qq.com(#替换成@)删除。