goodbest / u2.dmhy.org EVA 用户等级

// ==UserScript==
// @name         u2.dmhy.org EVA 用户等级
// @version      1.3
// @author       goodbest
// @match        http*://u2.dmhy.org/forums.php*
// @match        http*://u2.dmhy.org/userdetails.php*
// @match        http*://u2.dmhy.org/details.php*
// @match        http*://u2.dmhy.org/friends.php*
// @match        http*://u2.dmhy.org/showup.php*
// @match        http*://u2.dmhy.org/offers.php*
// @require      http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.3.min.js
// @run-at       window-load
// ==/UserScript==

var ori = {'pic/banned.gif'        : 0,
           'pic/peasant.gif'       : 1,  'Peasant_Name'       : 1,
           'pic/user.gif'          : 2,  'User_Name'          : 2,
           'pic/power.gif'         : 3,  'PowerUser_Name'     : 3,
           'pic/elite.gif'         : 4,  'EliteUser_Name'     : 4,
           'pic/crazy.gif'         : 5,  'CrazyUser_Name'     : 5,
           'pic/insane.gif'        : 6,  'InsaneUser_Name'    : 6,
           'pic/veteran.gif'       : 7,  'VeteranUser_Name'   : 7,
           'pic/extreme.gif'       : 8,  'ExtremeUser_Name'   : 8,
           'pic/ultimate.gif'      : 9,  'UltimateUser_Name'  : 9,
           'pic/nexus.gif'         : 10, 'NexusMaster_Name'   : 10,
           'pic/vip.gif'           : 11, 'VIP_Name'           : 11,
           'pic/retiree.gif'       : 12, 'Retiree_Name'       : 12,
           'pic/uploader.gif'      : 13, 'Uploader_Name'      : 13,
           'pic/moderator.gif'     : 14, 'Moderator_Name'     : 14,
           'pic/administrator.gif' : 15, 'Administrator_Name' : 15,
           'pic/sysop.gif'         : 16, 'SysOp_Name'         : 16,
           'pic/staffleader.gif'   : 17, 'StaffLeader_Name'   : 17}

var mod = Array(Array('attachments/201506/20150602234129bfe1405a6d1b3a9288f6dde6f73171f5.jpg', '第n次冲击'),
                Array('attachments/201501/2015012123543264c14664248b39fdf9c57d46c968c476.png', '第一使徒'),
                Array('attachments/201501/2015012123544045b43d5408e257b8bce88250fbd76096.png', '第二使徒'),
                Array('attachments/201501/201501212354466b0d67b96a69491fdd3bdc13abeabb8a.png', '第三使徒'),
                Array('attachments/201501/2015012123545300a7e9e7addfa2acc15bfaf295426ff6.png', '第四使徒'),
                Array('attachments/201501/201501212355008a1f0c850a75b6f6ba250e9ea1d4b7a7.png', '第五使徒'),
                Array('attachments/201501/201501212355084849de09395d2459eb6cae0b2eaf242d.png', '第六使徒'),
                Array('attachments/201501/20150121235516dccec29d7be86984d8bd3f137c251ece.png', '第七使徒'),
                Array('attachments/201501/2015012123552341b30fd13b9913a12aea5ba318bbc325.png', '第八使徒'),
                Array('attachments/201501/20150121235530a037aa9256d285e9528d21785821faf4.png', '第九使徒'),
                Array('attachments/201501/20150121235537fdfdd66b7c53f15e748dd0f7ef267a07.png', '第十使徒'),
                Array('attachments/201501/201501212355454026a361042b49addf8515260f88cf5f.png', '第十一使徒'),
                Array('attachments/201501/20150121235552447d87ba5a7a8abc6074a1038ef836b5.png', '第十二使徒'),
                Array('attachments/201501/20150121235559fef730d10ef9526b46912d3cb891cfbd.png', '第十三使徒'),
                Array('attachments/201501/20150121235605f20aca78eb4ac312047e4afd1232657e.png', '第十四使徒'),
                Array('attachments/201501/20150121235613cb379c6dda4f810e974983fb269aeaa8.png', '第十五使徒'),
                Array('attachments/201501/20150121235620f91e48360e180577838835e85d93eb6c.png', '第十六使徒'),
                Array('attachments/201501/2015012123563061e200c4938a18485b3501c088645a68.png', '第十七使徒'))

function replaceName(){
    var t = ori[$(this).attr('class')]
    if(typeof(t) != 'undefined')
        $(this).html(mod[t][1])
}

function replaceImg(){
    var t = ori[$(this).attr('src')]
    if(typeof(t) != 'undefined'){
        if($.inArray(window.location.pathname, ['/forums.php']) != -1){
            $(this).parent().children().remove('br')
            $(this).parent().contents().each(function(){if(this.nodeType != 1)this.remove()})
            $(this).prev().width(128)
            $(this).css('border-top', '#00aa00 1px solid')
        }
        $(this).attr({'alt': mod[t][1], 'title': mod[t][1], 'src':mod[t][0], 'width':128})
    }
}

function addImgToLiving(){
    var x = $(this).parentsUntil('td.text').next('table.main')
    var t = ori[$(this).attr('class')]
    if(typeof(x.find(':first>:first>:first>img[alt!="avatar"]')[0]) == 'undefined' && (t + 1)){
        x.find('img[alt="avatar"]').width(128)
        x.find('img[alt="avatar"]').after('<img alt="' + mod[t][1] + '" title="' + mod[t][1] + '" src="' + mod[t][0] + '"width=128 style="border-top: #00aa00 1px solid">')
    }
}

function addImgToDead(){
    var x = $(this).parentsUntil('td.text').next('table.main')
    if(typeof(x.find(':first>:first>:first>img[alt!="avatar"]')[0]) == 'undefined'){
        x.find('img[alt="avatar"]').width(128)
        x.find('img[alt="avatar"]').after('<img alt="' + mod[0][1] + '" title="' + mod[0][1] + '" src="' + mod[0][0] + '"width=128 style="border-top: #00aa00 1px solid">')
    }
}

$('b[class$="_Name"]').each(replaceName)
if($.inArray(window.location.pathname, ['/details.php', '/offers.php']) != -1){
        $('a[class$="_Name"]').each(addImgToLiving)
        $('a[name]+font+span>i>s').each(addImgToDead)
}

if($.inArray(window.location.pathname, ['/forums.php', '/userdetails.php']) != -1)
        $('img[src^="pic/"][src$=".gif"]').each(replaceImg)