PT彩虹ID

装逼专用,博君一笑

目前為 2020-09-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name         PT彩虹ID
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  装逼专用,博君一笑
// @author       陶陶滔滔涛
// @match        https://springsunday.net/*
// @match        https://hdsky.me/*
// @match        https://pt.keepfrds.com/*
// @match        https://chdbits.co/*
// @match        https://ourbits.club/*
// @match        https://tjupt.org/*
// @match        https://pterclub.com/*
// @match        https://hdchina.org/*
// @match        https://pt.hd4fans.org/*
// @match        https://hdhome.org/*
// @match        https://pthome.net/*
// @match        https://open.cd/*
// @match        https://nanyangpt.com/*
// @match        https://yingk.com/*
// @match        https://pt.soulvoice.club/*
// @match        https://www.nicept.net/*
// @match        https://avgv.cc/*
// @match        https://www.beitai.pt/*
// @match        https://leaguehd.com/*
// @match        https://pt.sjtu.edu.cn/*
// @match        https://www.hddolby.com/*
// @match        https://lbj007.com/*
// @match        https://ptsbao.club/*
// @match        https://www.hdarea.co/*
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @grant        none
// ==/UserScript==

$(document).ready(function() {
    action();
});

$(document).ajaxComplete(function(){
    action();
});

function action() {
    var url = decodeURI(location.href);

    var username = $("#info_block a[class$='Name'] b");
    if (url.match(/http(s*):\/\/hdchina.org.*/i)) {
        username = $(".userinfo a[class$='Name'] b");
    } else if (url.match(/http(s*):\/\/springsunday.net.*/i)) {
        username = $("#info_block b span[class$='Name']");
    } else if (url.match(/http(s*):\/\/pt.sjtu.edu.cn.*/i)) {
        username = $("#usermsglink a[class$='Name'] b");
    }
    var clazz = $(username).parent().attr('class');
    if (url.match(/http(s*):\/\/springsunday.net.*/i)) {
        clazz = $(username).attr('class');
    }
    console.log(clazz);

    var name = $(username).text();
    console.log(name)

    var array = $('.' + clazz + ' b');
    if (url.match(/http(s*):\/\/springsunday.net.*/i)) {
        array = $('.' + clazz);
    }
    array.each(function(index, item) {
        if ($(item).text().startsWith(name)) {
            rainbowize($(item));
        }
    });
}

function color_from_hue(hue) {
    var h = hue/90;
    var c = 255;
    var x = (1 - Math.abs(h%2 - 1))*255;
    var color;

    var i = Math.floor(h);
    if (i == 0) color = rgb_to_hex(c, x, 0);
    else if (i == 1) color = rgb_to_hex(x, c, 0);
    else if (i == 2) color = rgb_to_hex(0, c, x);
    else if (i == 3) color = rgb_to_hex(0, x, c);
    else if (i == 4) color = rgb_to_hex(x, 0, c);
    else color = rgb_to_hex(c, 0, x);

    return color;
}

function rgb_to_hex(red, green, blue) {
    var h = ((red << 16) | (green << 8) | (blue)).toString(16);
    // add the beginning zeros
    while (h.length < 6) h = '0' + h;
    return '#' + h;
}

function rainbowize(item) {
    $(item).each(function() {
            var rainbowtext = '';
            var hue=0;
            var step=0;

            // get the current text inside element
            var text = $(this).text();

            // hue is 360 degrees
            if (text.length > 0)
                step = 360 / (text.length);

            // iterate the whole 360 degrees
            for (var i = 0; i < text.length; i++)
            {
                rainbowtext = rainbowtext + '<span style="color:' + color_from_hue(hue) + '">' + text.charAt(i) + '</span>';
                hue += step;
            }

            $(this).html(rainbowtext);
    });
};

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址