goodbest / u2.dmhy.org 舰队Collection 用户等级

// ==UserScript==
// @name         u2.dmhy.org 舰队Collection 用户等级
// @version      1.1
// @author       风船葛
// @match        http*://u2.dmhy.org/forums.php*
// @match        http*://u2.dmhy.org/userdetails.php*
// @match        http*://u2.dmhy.org/details.php*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.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/201501/20150118145034e9912366f8e91c36ea4a0d82ec54b0fa.jpg', '泰坦尼克'),
                Array('attachments/201501/2015011814501718f7a5a5580f9d39cda09b029d00cd78.jpg', '非洲提督'),
                Array('attachments/201501/20150116192040ccb1b9e41fe58a56923efcb13b6c542f.jpg', '吹雪'),
                Array('attachments/201501/20150116192118697f92e83859e52d8226b1c86f8fd6d8.jpg', '伊58'),
                Array('attachments/201501/20150116192122ed542856d35e96f28803f3104426642e.jpg', '伊401'),
                Array('attachments/201501/20150116192021b5d82cf2bcba079281b51a2ca57c0042.jpg', 'Z1'),
                Array('attachments/201501/20150121214702fdfdd66b7c53f15e748dd0f7ef267a07.png', 'done?'),
                Array('attachments/201501/2015011619212509312c777635ba99d7fd7d7f11956b2e.png', '长门'),
                Array('attachments/201501/2015011619210504a1f73f4a4d0e6702c10bce1423668c.jpg', '加贺'),
                Array('attachments/201501/201501161920544c07e8577f24d0dc8782af61292f2ebf.jpg', '大和'),
                Array('attachments/201501/201501161920290a325a9f61d86f6e448e3443bc816b48.png', '赤城'),
                Array('attachments/201501/2015011619311445f12d243f773008f42e1b9c6d3b53a7.png', '那珂'),
                Array('attachments/201501/20150118145029e729360e8a52cbd1ae494a7dd5ccd176.jpg', '甘地'),
                Array('attachments/201501/201501161921147a8e646db60e4c056b202558ea464e2f.png', '响'),
                Array('attachments/201501/201501161920345376bdf8189efd8c85f564c5061a0f1f.png', '川内'),
                Array('attachments/201501/20150116192044340b4d153a1b29d109ebf8224bd5770d.jpg', '大凤'),
                Array('attachments/201501/2015012121464361e200c4938a18485b3501c088645a68.png', '1'),
                Array('attachments/201501/20150118145023429d4b4dfe27a96ef60ba99b4063fd21.jpg', '欧洲提督'))

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(window.location.pathname == '/forums.php'){
            $(this).parent().children().remove('br')
            $(this).parent().contents().each(function(){if(this.nodeType != 1)this.remove()})
            $(this).prev().width(160)
            $(this).css('border-top', '#00aa00 1px solid')
        }
        $(this).attr({'alt': mod[t][1], 'title': mod[t][1], 'src':mod[t][0]})
    }
}

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

$('b[class$="_Name"]').each(replaceName)
if(window.location.pathname == '/forums.php')
        $('a[class$="_Name"]').each(addImg)
if(window.location.pathname != '/details.php')
        $('img[src^="pic/"][src$=".gif"]').each(replaceImg)