// ==UserScript==
// @name 原神内鬼吧, 显示发帖用户ID和关注
// @namespace https://tieba.baidu.com/
// @description 显示发帖用户ID,点击ID可查看关注贴吧等级
// @author 你的名字
// @version 0.1.2
// @license MIT
// @match https://tieba.baidu.com/*%E5%8E%9F%E7%A5%9E%E5%86%85%E9%AC%BC*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function () {
'use strict';
(()=>{"use strict";var t={374:function(t,e,s){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const n=i(s(59)),a=s(633);function o(t,e){const s=t.getAttribute("title");if(console.log(s),null==s)return"";const i=s.match(/主题作者: ([^\\n]+)/);return i?i[1]:""}a.CSSInserter.insertExternalCSS(a.cssUrls);const l=new n.default("82ToolDialog");setInterval((function(){l.addUserId($(".tb_icon_author"),"span.id-span",o,null)}),1e3)},633:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.cssUrls=e.CSSInserter=void 0,e.CSSInserter=class{static insertExternalCSS(t){t.forEach((t=>{const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}))}},e.cssUrls=["https://tb1.bdstatic.com/??/tb/_/my_current_forum_274c0a1.css,/tb/_/tb_spam_814ec43.css,/tb/_/my_tieba_4a1aa01.css,/tb/_/rich_ueditor_3283067.css,/tb/_/pic_act_poster_38b0720.css,/tb/_/follower_bc7c9ff.css,/tb/_/forum_title_a7a033e.css,/tb/_/novel_icons_8d150ae.css,/tb/_/save_face_fa1020d.css,/tb/_/pb_marry_ecbd581.css,/tb/_/fengchao_pb_feed_c7fdae2.css,/tb/_/promoter_master_house_9b0d01e.css,/tb/_/promoter_fans_supprise_bba005a.css,/tb/_/residual_87ce152.css,/tb/_/single_icons_3112de2.css,/tb/_/pb_author_d843ad0.css,/tb/_/novel_award_dialog_7b95981.css,/tb/_/novel_award_thread_d41d8cd.css,/tb/_/diamond_bind_mob_603bf34.css,/tb/_/grab_treasure_report_1152cd7.css,/tb/_/treasure_payment_dialog_de1650b.css,/tb/_/treasure_rule_dialog_021b23c.css,/tb/_/grab_treasure_ctrl_47136a4.css,/tb/_/pb_grab_treasure_2be04cb.css,/tb/_/scroll_panel_eb74727.css,/tb/_/promoter_post_opts_df5e95d.css,/tb/_/promoter_post_body_5da1d7c.css,/tb/_/post_tpoint_skin_dc0a7bb.css,/tb/_/idisk_3de9e3d.css,/tb/_/paypost_guide_2bcd461.css"]},59:function(t,e,s){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const n=i(s(218)),a=i(s(915));e.default=class{constructor(t){const e=document.getElementById(t);null!=e&&e instanceof HTMLDivElement?(this.container=e,this.container.replaceChildren()):(this.container=document.createElement("div"),this.container.id=t,document.body.appendChild(this.container)),this.replyUrl=document.createElement("a"),this.brElement=document.createElement("br"),this.tagManager=new a.default("TagManager"),this.subscribeLevelElement=document.createElement("div"),this.initializeStyles(),this.initializeDialog()}initializeStyles(){this.container.style.position="absolute",this.container.style.zIndex="9999",this.container.style.backgroundColor="#f8f4f4",this.container.style.border="1px solid #ccc",this.container.style.borderRadius="10px",this.container.style.padding="10px",this.container.style.boxShadow="0 4px 6px rgba(0, 0, 0, 0.1)",this.container.style.width="230px",this.container.style.display="none"}initializeDialog(){this.replyUrl.href="#",this.replyUrl.target="_blank",this.replyUrl.textContent="查看用户历史发言",this.container.appendChild(this.replyUrl),this.container.appendChild(this.brElement),this.container.appendChild(this.tagManager.getElement()),this.subscribeLevelElement.style.display="grid",this.subscribeLevelElement.style.gridTemplateColumns="repeat(2, 1fr)",this.subscribeLevelElement.style.gap="10px",this.container.appendChild(this.subscribeLevelElement),$(document).on("click",(t=>{$(t.target).closest("#82ToolDialog").length||$(t.target).closest("span").length||(this.tagManager.close(),this.container.style.display="none")}))}showDialog(t){const e=t.clientX,s=t.clientY,i=window.scrollY||document.documentElement.scrollTop,n=this.container.offsetWidth,a=this.container.offsetHeight;this.container.style.display="none",this.container.style.left=e-n/2+"px",this.container.style.top=s+i-a-10+"px",this.container.style.display="block"}addUserId(t,e,s,i){t.each(((t,a)=>{if(0==$(a).find(`span.${n.default.className}`).length){const t=s(a,e),o=new n.default(t),l=encodeURIComponent(t);o.setOnClick((e=>{this.showDialog(e),this.tagManager.load(t),this.requestDataFrom82Tool(l)})),null!=i&&$(a).prepend(i()),$(a).prepend(o.getElement())}}))}setReplyHref(t){this.replyUrl.href=`https://www.82cat.com/tieba/reply/${t}/1`}addSubscribe(t){this.subscribeLevelElement.replaceChildren(),0==t.length?this.subscribeLevelElement.innerHTML="<span>无查询结果</span>":(t.sort(((t,e)=>e.level-t.level)),t.forEach((t=>{if(t.level>=4){const e=document.createElement("div");e.className="p_badge";const s=Math.min(Math.floor(t.level/5)+1,4);e.innerHTML=`<a class="user_badge d_badge_bright d_badge_icon${s}"><div class="d_badge_title" title="${t.name}" style="overflow: hidden; text-overflow: ellipsis">${t.name}</div><div class="d_badge_lv">${t.level}</div></a>`,this.subscribeLevelElement.appendChild(e)}})))}requestDataFrom82Tool(t){const e=this;GM_xmlhttpRequest({method:"GET",url:`https://www.82cat.com/tieba/forum/${t}/1`,onload:function(s){console.log("成功响应");const i=s.responseText,n=e.getSubscribeTieBa(i);e.setReplyHref(t),e.addSubscribe(n)},onerror:t=>{console.error("请求失败:",t)},ontimeout:()=>{console.error("请求超时")}})}getSubscribeTieBa(t){const e=$(t),s=[];return e.find("tr").each(((t,e)=>{const i=$(e).find("td");if(i.length>=3){const t=i.eq(0).text().trim(),e=i.eq(2).find(".badge").text().trim(),n=parseInt(e,10);isNaN(n)||s.push({name:t,level:n})}})),s}}},915:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){const e=document.getElementById(t);null==e?(this.container=document.createElement("div"),this.container.id=t,this.container.replaceChildren()):this.container=e,this._username=null,this.tagListContainer=document.createElement("div"),this.inputField=document.createElement("input"),this.addButton=document.createElement("button"),this.initialize()}initialize(){this.tagListContainer.style.display="flex",this.tagListContainer.style.flexWrap="wrap",this.tagListContainer.style.gap="10px",this.tagListContainer.style.padding="10px",this.tagListContainer.style.borderRadius="10px",this.tagListContainer.style.backgroundColor="#f0f0f0",this.tagListContainer.style.marginBottom="10px",this.tagListContainer.style.maxWidth="100%",this.tagListContainer.style.boxSizing="border-box",this.container.appendChild(this.tagListContainer),this.inputField.placeholder="输入标签,用分号分隔",this.inputField.style.marginBottom="10px",this.inputField.style.padding="5px",this.inputField.style.width="calc(100% - 85px)",this.inputField.style.border="none",this.inputField.style.outline="none",this.inputField.style.fontSize="14px";const t=document.createElement("div");t.style.height="1px",t.style.backgroundColor="#ccc",t.style.marginBottom="10px",this.container.appendChild(t),this.addButton.textContent="添加标签",this.addButton.style.marginLeft="10px",this.addButton.style.padding="5px",this.addButton.addEventListener("click",(()=>this.addTags())),this.container.appendChild(this.inputField),this.container.appendChild(this.addButton),this.loadTags()}addTags(){const t=this.inputField.value.trim();if(!t)return;const e=t.split(";").map((t=>t.trim())).filter((t=>t));this.addTagsToLocalStorage(e),e.forEach((t=>this.createTag(t))),this.inputField.value=""}addTagsToLocalStorage(t){const e=[...this.getTagsFromLocalStorage(),...t];null!=this._username&&this._username.length>0&&localStorage.setItem(this._username,JSON.stringify(e))}getTagsFromLocalStorage(){if(null==this._username||0==this._username.length)return[];const t=localStorage.getItem(this._username);return t?JSON.parse(t):[]}createTag(t){const e=document.createElement("div");e.className="tag",e.textContent=t,e.style.position="relative",e.style.backgroundColor="red",e.style.color="white",e.style.padding="5px 10px",e.style.borderRadius="15px",e.style.fontSize="14px",e.style.display="inline-flex",e.style.alignItems="center",e.style.maxWidth="200px";const s=document.createElement("span");s.className="closeButton",s.textContent="×",s.style.position="absolute",s.style.top="0",s.style.right="0",s.style.cursor="pointer",s.style.padding="0 5px",s.style.fontWeight="bold",s.addEventListener("click",(()=>this.removeTag(e))),e.appendChild(s),this.tagListContainer.appendChild(e)}removeTag(t){var e;const s=null===(e=t.textContent)||void 0===e?void 0:e.trim();s&&this.removeTagFromLocalStorage(s),t.remove()}removeTagFromLocalStorage(t){const e=this.getTagsFromLocalStorage().filter((e=>e!==t));localStorage.setItem("tags",JSON.stringify(e))}loadTags(){this.getTagsFromLocalStorage().forEach((t=>this.createTag(t)))}getElement(){return this.container}close(){this._username=null,this.tagListContainer.replaceChildren()}load(t){this._username=t,this.loadTags()}}},218:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class s{constructor(t){this.container=document.createElement("span"),this.container.className=s.className,this.container.textContent=`🆔${t}`,this.initializeSpanStyles()}initializeSpanStyles(){this.container.style.backgroundColor="#f0e9e9",this.container.style.borderRadius="5px",this.container.style.color="#4e4747",this.container.style.border="solid 1px",this.container.style.borderColor="#e6e6e6",this.container.style.fontWeight="bold",this.container.style.marginRight="8px",this.container.style.display="inline-block",this.container.style.letterSpacing="normal"}setOnClick(t){$(this.container).on("click",(e=>{t(e)}))}getElement(){return this.container}}s.className="UserIdSpan",e.default=s}},e={};!function s(i){var n=e[i];if(void 0!==n)return n.exports;var a=e[i]={exports:{}};return t[i].call(a.exports,a,a.exports,s),a.exports}(374)})();
})();