// ==UserScript== // @name 贴吧高清头像查看 // @author 有一份田,Sonico俺の嫁,YIU // @description 可以查看贴吧用户的高清头像 // @namespace TieBaHDAvatar-youyifentian // @icon http://img.duoluohua.com/appimg/script_tiebahdavatar_icon_48.png // @license GPL version 3 // @encoding utf-8 // @date 09/12/2013 // @modified 05/08/2017 // @include *://tieba.baidu.com/p/* // @include *://tieba.baidu.com/f* // @include *://tieba.baidu.com/home/* // @grant none // @run-at document-end // @version 1.0.1 // @downloadURL none // ==/UserScript== /* * === 说明 === *@作者:有一份田,Sonico俺の嫁,YIU *@官网:http://www.duoluohua.com/download/ *@Email:youyifentian@gmail.com *@Git:http://git.oschina.net/youyifentian *@转载重用请保留此信息 * * * */ (function(){ var portraitCache = {}; $('body').bind('DOMNodeInserted',function(e){ var o = $(e.target).find('.interaction_wrap'); if(o.length){ createEleBtn(o); } }); function createEleBtn(o){ $('').addClass("btn-encourage btn-small user-visit-card-marriage-propose").click(function(){ var uname = o.parents('.ui_card_content').find('a.userinfo_username').html(); var hexUID = getHexUid(o.parents('.ui_card_content').find(".interaction_wrap a[target='sixin']")[0].href.match(/\d+$/g)); showHighAvatar(uname, hexUID); }).html('\u9ad8\u6e05\u5934\u50cf').prependTo(o); } function getHexUid(uid){ hexuid = FormatHex(parseInt(uid).toString(16)); reg = /[a-z\d]{2}/g; return hexuid.match(reg).reverse().toString().replace(/,/g,''); } function FormatHex( hex ){ zero = "00000000"; tmp = 8 - hex.length; return zero.substr(0, tmp) + hex; } function showHighAvatar(uname, hexuid){ var hdImgUrl = "https://gss0.baidu.com/7Ls0a8Sm2Q5IlBGlnYG/sys/portraitl/item/" + hexuid, httpHwnd = null, modal= new $.modal({show: true}),box=$('
').css({ "left":"50%", "top":"50%", "position":"fixed", "min-height":"240px", "min-width":"240px", "z-index":$.getzIndex() }).appendTo("body"), dialogClose = function(){ if(httpHwnd){httpHwnd.abort();} modal.remove(); box.remove(); }, loadingImg = $('').css({ "height":"32px", "width":"32px", "margin-left":"-16px", "margin-top":"-16px" }).appendTo(box), loadImg = function(){ var imgurl=hdImgUrl, img = new Image(); img.src = imgurl; img.onload = function(){ var h = img.height,w = img.width; loadingImg.remove(); $(img).css({ "height":h+"px", "width":w+"px", "margin-left":"-"+w/2+"px", "margin-top":"-"+h/2+"px", "border-radius":"3px", "box-shadow":"0 0 15px rgba(127, 173, 220, 0.8), 0 0 15px #7FADDC inset", "cursor":"url(\"https://tb2.bdstatic.com/tb/img/frs/cur_zout.cur\"), pointer" }).attr('title',uname).appendTo(box); }; }; loadImg(); box.click(dialogClose); modal.element.click(dialogClose); } })();