NGA_parse_uid

uid转用户名

اعتبارا من 18-01-2018. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         NGA_parse_uid
// @version      0.17
// @author       Inazuma
// @match        https://nga.178.com/*
// @match        https://bbs.ngacn.cc/*
// @match        https://bbs.nga.cn/*
// @match        http://nga.178.com/*
// @match        http://bbs.nga.cn/*
// @match        http://bbs.ngacn.cc/*
// @require      http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.3.min.js
// @grant       none
// @namespace https://greasyfork.org/users/163468
// @description uid转用户名
// ==/UserScript==

let pattern = 'nuke.php?func=ucp&uid=';
$('a[href*="' + pattern + '"]').each((i, v) => {
    let uid = v.href.split(pattern)[1];
    $.post('/nuke.php?uid=' + uid + '&__output=12&__act=get&__lib=ucp', res => {

        //uid to username
        let username = res.result.username;
        v.innerText = username;

        //add avatar
        let avatarDiv = $(v).parent().next();
        let avatar = res.result.avatar;
        if (avatar && (avatarDiv[0].className === 'stat')) {
            if (avatar.indexOf("{") < 0) {
                if (avatar.indexOf("http") < 0 || avatar.indexOf("bbs") >= 0) {
                    let file = avatar.match(/[0-9].*/);
                    let hex = parseInt(avatar.match(/[0-9]+/)[0]).toString(16);
                    avatar = "http://img.ngacn.cc/avatars/2002/";
                    while (hex.length < 9) {
                        hex = '0' + hex;
                    }
                    hex = hex.match(/.{1,3}/g);
                    for (let i = hex.length - 1; i >= 0; i--) {
                        avatar = avatar + hex[i] + '/';
                    }
                    avatar += file;
                }
            } else {
                avatar = JSON.parse(avatar);
                avatar = avatar[parseInt(Math.random() * avatar.l) + ""];
            }
            avatarDiv.before('<img style="max-width: 280px; margin: 5px auto; border-radius: 50%;" src="' + avatar + '">');
        }
    });
});

$('a[href="被禁止的链接"]').each((i, v) => {
    let link;
    if (v.parentNode.className !== 'nobr') {
        link = v.previousElementSibling.firstChild.innerText.replace(/<[^>]+>/g, '');
        v.setAttribute('href', link);
        v.innerText = v.innerText.replace(/被禁止的链接/g, link);
    } else {
        link = v.parentNode.parentNode.firstChild.innerText.replace(/<[^>]+>/g, '');
        v.setAttribute('href', link);
    }
});


//以下代码禁用了相关论坛代码,用于消除启用Tampermonkey脚本时发生的错误(大概不会有什么影响(不是我的锅,在nga上启用任何Tampermonkey脚本都会报错

commonui.quoteTo.hideWindow = function(){};
commonui.quoteTo.onmouseup = function(){};