原神内鬼吧, 显示发帖用户ID和关注

显示发帖用户ID,点击ID可查看关注贴吧等级

目前为 2024-11-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         原神内鬼吧, 显示发帖用户ID和关注
// @namespace    https://tieba.baidu.com/
// @description  显示发帖用户ID,点击ID可查看关注贴吧等级
// @author       你的名字
// @version      0.1.3
// @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 e={448:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(716)),o=n(s(633)),r=n(s(218)),a=n(s(171));o.default.insertTieBaLevelCSS();const l=new i.default;setInterval((function(){a.default.removeAD(),l.addUserId($(".tb_icon_author"),"span.frs-author-name-wrap > a",r.default.getUserNameFromDataField,null)}),1e3)},688:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static getSubscribeTieBa(e){const t=$(e),s=[];return t.find("tr").each(((e,t)=>{const n=$(t).find("td");if(n.length>=3){const e=n.eq(0).text().trim(),t=n.eq(2).find(".badge").text().trim(),i=parseInt(t,10);isNaN(i)||s.push({name:e,level:i})}})),s}static getReplyMessage(e){const t=$(e),s=[],n=/在([^:]+)吧回复:([^:]+):([^0-9]+)(\d{4}年\d{2}月\d{2}日 \d{2}时\d{2}分\d{2}秒)/;return t.find("ol.list-unstyled > li").each(((e,t)=>{const i=t.textContent;if(null!=i){const e=i.match(n);null!=e&&5==e.length&&s.push({avatar:e[1],title:e[2],content:e[3],timestamp:e[4]})}})),s}}},633:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s{static insertExternalCSS(e){e.forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}))}static insertTieBaLevelCSS(){s.insertExternalCSS(n)}static insertLoadingCSS(){const e=document.createElement("style");e.innerHTML="\n  #loadingContainer {\n    position: relative;\n    height: 70px;\n    padding: 20px;\n  }\n\n  #loading82Tool {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    width: 50px;\n    height: 50px;\n    border: 5px solid #f3f3f3; /* 背景色 */\n    border-top: 5px solid #3498db; /* 转圈部分的颜色 */\n    border-radius: 50%;\n    animation: spin 2s linear infinite;\n  }\n\n  @keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n  }\n",document.head.appendChild(e)}}t.default=s;const n=["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"]},259:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static loadDataBase(e){const t=indexedDB.open(e);t.onupgradeneeded=e=>{if(null!=e.target){const e=t.result;e.objectStoreNames.contains("users")||e.createObjectStore("users",{keyPath:"name",autoIncrement:!1})}},t.onerror=e=>{null!=t.error&&console.error("Database error: "+t.error.message)}}static addOrUpdateUser(e,t,s){const n=e.transaction("users","readwrite").objectStore("users").put({name:t,tags:s});n.onsuccess=()=>{console.log("User added to the database")},n.onerror=e=>{null!=n.error&&console.error("Error adding user: "+n.error.message)}}static getUser(e,t,s){const n=e.transaction("users","readonly").objectStore("users").get(t);n.onsuccess=e=>{const t=n.result;if(t){console.log("User found:",t);const e=t.tags;s(e)}else s([]),console.log("User not found")},n.onerror=e=>{null!=n.error&&console.error("Error retrieving user: "+n.error.message)}}static deleteUser(e,t){const s=e.transaction("users","readwrite").objectStore("users").delete(t);s.onsuccess=()=>{console.log("User deleted successfully")},s.onerror=e=>{null!=s.error&&console.error("Error deleting user: "+s.error.message)}}static exportDataToJSON(e,t){return new Promise(((s,n)=>{const i=e.transaction(t,"readonly").objectStore(t).getAll();i.onsuccess=()=>{const e=i.result,t=JSON.stringify(e,null,2);e.length>0?s(t):alert("标签数据为空,不需要导出文件")},i.onerror=e=>{null!=i.error&&n("Error exporting data: "+i.error.message)}}))}}},915:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(259));class o{constructor(){i.default.loadDataBase(o.localStorageId);const e=document.getElementById(o.containerId);null==e?(this.container=document.createElement("div"),this.container.id=o.containerId,this.container.replaceChildren()):this.container=e,this._username=null,this.tagListContainer=document.createElement("div"),this.inputField=document.createElement("input"),this.addButton=document.createElement("div"),this.importButton=document.createElement("div"),this.exportButton=document.createElement("div"),this.initialize()}initialize(){this.tagListContainer.style.display="flex",this.tagListContainer.style.flexWrap="wrap",this.tagListContainer.style.gap="10px",this.tagListContainer.style.padding="30px",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="5px",this.inputField.style.padding="5px",this.inputField.style.width="calc(100% - 10px)",this.inputField.style.border="none",this.inputField.style.outline="none",this.inputField.style.fontSize="14px";const e=(e,t)=>({display:"inline-block",padding:"2px 4px",backgroundColor:e,color:t,boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",border:"none",borderRadius:"5px",cursor:"pointer",fontSize:"12px",userSelect:"none",textAlign:"center",lineHeight:"18px",width:"55px",margin:"5px"});this.addButton.textContent="添加",Object.assign(this.addButton.style,e("#4CAF50","#fff")),this.exportButton.textContent="导出",Object.assign(this.exportButton.style,e("#2196F3","#fff")),this.importButton.textContent="导入",Object.assign(this.importButton.style,e("#18624d","#fff")),this.addButton.addEventListener("click",(()=>this.addTags())),this.importButton.addEventListener("click",(()=>this.importJson())),this.exportButton.addEventListener("click",(()=>o.exportJson())),this.container.appendChild(this.inputField),this.container.appendChild(this.addButton),this.container.appendChild(this.importButton),this.container.appendChild(this.exportButton),this.loadTags()}addTags(){const e=this.inputField.value.trim();if(!e)return;const t=e.split(/[;, ;]/).map((e=>e.trim())).filter((e=>e.length>0));this.addTagsToIndexedDB(t),t.forEach((e=>this.createTag(e))),this.inputField.value=""}addTagsToIndexedDB(e){this.getTagsFromIndexedDB((t=>{const s=Array.from(new Set([...t,...e]));if(null!=this._username&&this._username.length>0){console.log(`缓存标签, 用户名: ${this._username}, 已缓存标签: ${JSON.stringify(t)}, 新增标签: ${JSON.stringify(e)}`);const n=indexedDB.open(o.localStorageId),r=this._username;n.onsuccess=()=>{i.default.addOrUpdateUser(n.result,r,s)}}}))}getTagsFromIndexedDB(e){if(null==this._username||0==this._username.length)return;const t=indexedDB.open(o.localStorageId),s=this._username;t.onsuccess=()=>{const n=t.result;i.default.getUser(n,s,e)}}createTag(e){const t=document.createElement("div");t.className="tag",t.textContent=e,t.style.position="relative",t.style.backgroundColor="red",t.style.color="white",t.style.padding="5px 10px",t.style.borderRadius="15px",t.style.fontSize="12px",t.style.display="inline-flex",t.style.alignItems="center",t.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(t))),t.appendChild(s),this.tagListContainer.appendChild(t)}removeTag(e){var t;const s=null===(t=e.textContent)||void 0===t?void 0:t.trim().slice(0,-1);s&&this.removeTagFromIndexedDB(s),e.remove()}removeTagFromIndexedDB(e){this.getTagsFromIndexedDB((t=>{const s=t.filter((t=>t!==e));if(null!=this._username&&this._username.length>0){console.log(`清除缓存标签, 用户名: ${this._username}, 已缓存标签: ${JSON.stringify(t)}, 删除标签: ${e}`);const n=indexedDB.open(o.localStorageId),r=this._username;n.onsuccess=()=>{const e=n.result;s.length>0?i.default.addOrUpdateUser(e,r,s):i.default.deleteUser(e,r)}}}))}loadTags(){this.getTagsFromIndexedDB((e=>{e.forEach((e=>this.createTag(e)))}))}getElement(){return this.container}close(){this._username=null,this.tagListContainer.replaceChildren()}load(e){this._username=e,this.loadTags()}importJson(){alert("导入外部文件会覆盖当前标签内容, 点击确定继续导入");const e=document.createElement("input");e.type="file",e.style.display="none",e.click(),e.addEventListener("change",(e=>{const t=e.target,s=t.files?t.files[0]:null;s&&o.readJsonFile(s)}))}static exportJson(){const e=indexedDB.open(o.localStorageId);e.onsuccess=t=>{const s=e.result;i.default.exportDataToJSON(s,"users").then((e=>{console.log("Exported JSON:",e);const t=new Blob([e],{type:"application/json"}),s=document.createElement("a");s.href=URL.createObjectURL(t),s.download="data.json",s.click()})).catch(console.error)}}static readJsonFile(e){const t=new FileReader;t.onload=()=>{const e=t.result;try{const t=JSON.parse(e),s=indexedDB.open(o.localStorageId);s.onsuccess=e=>{const n=s.result;t.forEach((e=>i.default.addOrUpdateUser(n,e.name,e.tags))),alert("导入成功, 将在下次点击用户ID时生效")}}catch(e){alert("Error parsing JSON file")}},t.onerror=()=>{alert("Error reading file")},t.readAsText(e)}}o.containerId="tagManager",o.localStorageId="tagManagerZojdsa321e1w4q3456wq",t.default=o},171:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s{static removeAD(){$("[id^='mediago']").each(((e,t)=>{t.style.display="none"}))}static loadSubscribeFromSession(e){const t=sessionStorage.getItem(e);return null!=t?(console.log("从当前会话加载贴吧关注信息成功"),JSON.parse(t)):null}static saveSubscribeToSession(e,t){if(null!=t&&t.length>0){console.log("缓存贴吧关注信息到当前会话");const n=s.loadSubscribeFromSession(e);if(null!=n){const s=Array.from(new Set([...n,...t].map((e=>JSON.stringify(e))))).map((e=>JSON.parse(e)));sessionStorage.setItem(e,JSON.stringify(s))}else{const s=Array.from(new Set(t.map((e=>JSON.stringify(e))))).map((e=>JSON.parse(e)));sessionStorage.setItem(e,JSON.stringify(s))}}}}t.default=s},716:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(218)),o=n(s(915)),r=n(s(633)),a=n(s(171)),l=n(s(688));class c{constructor(){const e=document.getElementById(c.containerId);null!=e&&e instanceof HTMLDivElement?(this.container=e,this.container.replaceChildren()):(r.default.insertLoadingCSS(),this.container=document.createElement("div"),this.container.id=c.containerId,document.body.appendChild(this.container)),this.replyUrl=document.createElement("a"),this.brElement=document.createElement("br"),this.tagManager=new o.default,this.subscribeLevelElement=document.createElement("div"),this.loadingElement=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());const e=document.createElement("div");e.style.height="1px",e.style.backgroundColor="#ccc",e.style.marginBottom="10px",this.container.appendChild(e),this.subscribeLevelElement.style.display="grid",this.subscribeLevelElement.style.gridTemplateColumns="repeat(2, 1fr)",this.subscribeLevelElement.style.gap="10px",this.subscribeLevelElement.style.maxHeight="350px",this.subscribeLevelElement.style.overflowY="scroll",this.subscribeLevelElement.style.scrollbarWidth="none",this.container.appendChild(this.subscribeLevelElement),this.loadingElement.style.all=this.subscribeLevelElement.style.all,this.loadingElement.id="loadingContainer";const t=document.createElement("div");t.id="loading82Tool",this.loadingElement.appendChild(t),this.container.appendChild(this.loadingElement),$(document).on("click",(e=>{$(e.target).closest(`#${c.containerId}`).length||$(e.target).closest("span").length||(this.tagManager.close(),this.container.style.display="none")}))}showDialog(e){const t=e.clientX,s=e.clientY,n=window.scrollY||document.documentElement.scrollTop,i=this.container.offsetWidth,o=this.container.offsetHeight;this.container.style.display="none",this.subscribeLevelElement.replaceChildren(),this.container.style.left=t-i/2+"px",this.container.style.top=s+n-o-10+"px",this.container.style.display="block"}addUserId(e,t,s,n){e.each(((e,o)=>{if(0==$(o).find(`span.${i.default.className}`).length){const e=s(o,t),r=new i.default(e);r.setOnClick((t=>{this.setLoading(),this.showDialog(t),this.tagManager.load(e);const s=a.default.loadSubscribeFromSession(e);if(null!=s){const t=encodeURIComponent(e);this.setReplyHref(t),this.addSubscribe(s)}else this.requestSubscribeFrom82Tool(e,1)})),null!=n&&$(o).prepend(n()),$(o).prepend(r.getElement())}}))}setReplyHref(e){this.replyUrl.href=`https://www.82cat.com/tieba/reply/${e}/1`}addSubscribe(e){0==e.length?this.subscribeLevelElement.innerHTML="<span>无查询结果</span>":(e.sort(((e,t)=>t.level-e.level)),e.forEach((e=>{if(e.level>=4){const t=document.createElement("div");t.className="p_badge";const s=Math.min(Math.floor(e.level/5)+1,4);t.innerHTML=`<a class="user_badge d_badge_bright d_badge_icon${s}"><div class="d_badge_title" title="${e.name}" style="overflow: hidden; text-overflow: ellipsis">${e.name}</div><div class="d_badge_lv">${e.level}</div></a>`,this.subscribeLevelElement.appendChild(t)}}))),this.finishLoading()}requestSubscribeFrom82Tool(e,t){const s=encodeURIComponent(e);this.setReplyHref(s);const n=this;GM_xmlhttpRequest({method:"GET",url:`https://www.82cat.com/tieba/forum/${s}/${t}`,onload:function(s){console.log("成功响应, 当前页面: ",t);const i=s.responseText,o=l.default.getSubscribeTieBa(i);if(o.length>0&&"none"!=n.container.style.display){n.addSubscribe(o);const s=a.default.loadSubscribeFromSession(e);a.default.saveSubscribeToSession(e,o);const i=a.default.loadSubscribeFromSession(e);(null==s||null!=i&&s.length<i.length)&&n.requestSubscribeFrom82Tool(e,t+1)}else 1==t&&n.addSubscribe(o),console.log("查询关注信息完毕")},onerror:e=>{console.error("请求失败:",e)},ontimeout:()=>{console.error("请求超时")}})}setLoading(){this.subscribeLevelElement.style.display="none",this.loadingElement.style.display="block"}finishLoading(){this.subscribeLevelElement.style.display="grid",this.loadingElement.style.display="none"}}c.containerId="82ToolDialog",t.default=c},218:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s{constructor(e){this.container=document.createElement("span"),this.container.className=s.className,this.container.textContent=`🆔${e}`,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(e){$(this.container).on("click",(t=>{e(t)}))}getElement(){return this.container}static getUserNameFromDataField(e,t){let n=$(e).find(t).attr("data-field");if(null==n)return"";n=n.replace(/'([^']*)'/g,'"$1"');const i=JSON.parse(n).un;return null==i||0==i.length?s.getUserNameFromTitle(e):i}static getUserNameFromTitle(e){const t=e.getAttribute("title");if(null==t)return"";const s=t.match(/主题作者: ([^\n]+)/);return s?s[1]:""}}s.className="UserIdSpan",t.default=s}},t={};!function s(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,s),o.exports}(448)})();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址