// ==UserScript== // @name 原神玩家指示器 // @namespace www.cber.ltd // @version 0.2 // @description B站评论区自动标注原神玩家,依据是动态里是否有原神相关内容。 // @author xulaupuz // @match https://www.bilibili.com/video/* // @icon https://static.hdslb.com/images/favicon.ico // @grant GM_xmlhttpRequest // @license MIT // @run-at document-end // @downloadURL none // ==/UserScript== (function() { 'use strict'; //console.log("正常加载") let jiance = setInterval(()=>{ var commentlist = document.getElementsByClassName('user') if (commentlist.length != 0){ clearInterval(jiance) commentlist.forEach(c => { let pid = c.children[0]['href'].replace(/[^\d]/g, "") //console.log(pid) let blogurl = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?&host_mid=' + pid let xhr = new XMLHttpRequest() GM_xmlhttpRequest({ method: "get", url: blogurl, data: '', headers: { 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' }, onload: function(res){ if(res.status === 200){ //console.log('成功') let dt = JSON.parse(res.response).data let st = JSON.stringify(dt) if (st.includes('原神')){ c.append('|原神玩家|') } }else{ console.log('失败') console.log(res) } }, }); }); } else{ console.log('获取Dom失败') } },2000) })();