// ==UserScript== // @name 贴吧显示真实ID // @version 0.18 // @namespace https://github.com/8qwe24657913 // @description 贴吧昵称掩盖了真实ID,认不出人了?这个脚本适合你 // @author 8qwe24657913 // @match http://tieba.baidu.com/* // @match https://tieba.baidu.com/* // @run-at document-start // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant unsafeWindow // @downloadURL https://update.greasyfork.icu/scripts/31207/%E8%B4%B4%E5%90%A7%E6%98%BE%E7%A4%BA%E7%9C%9F%E5%AE%9EID.user.js // @updateURL https://update.greasyfork.icu/scripts/31207/%E8%B4%B4%E5%90%A7%E6%98%BE%E7%A4%BA%E7%9C%9F%E5%AE%9EID.meta.js // ==/UserScript== /* globals GM_getValue GM_setValue GM_registerMenuCommand unsafeWindow */ // eslint-disable-next-line no-extra-semi ;(function() { 'use strict' // add css const css = ` @keyframes showUserName { from { clip: rect(1px, auto, auto, auto); } to { clip: rect(0px, auto, auto, auto); } } .frs-author-name:not(.shownUN), .p_author_name:not(.shownUN), .userinfo_username:not(.shownUN), .lzl_cnt > .at:not(.shownUN), .lzl_content_main > .at:not(.shownUN), #j_u_username .u_ddl_con_top > ul:not(.shownUN) { animation-duration: 0.001s; animation-name: showUserName; } .card_userinfo_title .userinfo_username, .card_userinfo_title .userinfo_username:hover { max-width: 100%!important; } .userinfo_username + div[style]:not([class]):not([id]), img[src="//tb1.bdstatic.com/tb/cms/nickemoji/nickname_sign.png"], .card_userinfo_tbvip { display: none!important; } .frs-author-name > div[style*="color"], .userinfo_username > div[style*="color"] { color: inherit!important; } ` const style = document.createElement('style') style.appendChild(document.createTextNode(css)) document.documentElement.appendChild(style) // add setting // eslint-disable-next-line no-template-curly-in-string const setting = GM_getValue('showUNSetting', localStorage.showUNSetting || '${un} (${nickname})') function changeSetting() { // eslint-disable-next-line no-template-curly-in-string const newSetting = prompt('${un}表示真实ID,${nickname}表示昵称,可使用html标签', setting) if (newSetting && newSetting !== setting) { GM_setValue('showUNSetting', newSetting) location.reload() } } GM_registerMenuCommand('设置贴吧显示真实ID格式', changeSetting) function closestAttr(elem, attr) { while (elem && !elem.hasAttribute(attr)) elem = elem.parentElement return elem ? elem.getAttribute(attr) : false } function decodeURL(str) { try { // decode utf-8 return decodeURIComponent(str) } catch (e) { // decode gbk const decoder = new TextDecoder('gbk') return str.replace(/(?:%[A-Z0-9]{2})+/gi, s => decoder.decode( new Uint8Array( s .substr(1) .split('%') .map(c => parseInt(c, 16)), ), ), ) } } // main document.addEventListener( 'animationstart', event => { // shouldn't use jQuery if (event.animationName !== 'showUserName') return const target = event.target target.classList.add('shownUN') if (target.nodeName === 'UL') { // 设置按钮 target.insertAdjacentHTML('beforeend', '