更新迷你资料卡

This commit is contained in:
woohoo 2021-11-14 17:48:51 +08:00
parent 846abad5b0
commit a866df68f7

View File

@ -940,32 +940,67 @@
}, 1000); }, 1000);
/** /**
* 浮窗 todo * 迷你资料卡 全局 todo
* 小型资料卡 全局
*/ */
let tooltip = $('div.ToolTipPortal')[0]; const miniProfile = function miniprof() {
let intervalID = setInterval(() => { const miniprofOB = new MutationObserver(_ => {
tooltip = $('div.ToolTipPortal')[0]; miniprofOB.disconnect();
if (tooltip) { miniprofTrans();
clearInterval(intervalID); miniprofOB.observe($('div.profile-mini-root').get(0), {attributes: true, childList: true, subtree: true});
new MutationObserver(mutations => { });
let barDescr = $('div[class^="tooltip"]').children('p[class^="bar-descr"]'); const miniprofTrans = function miniprofTrans(){
if (barDescr.length !== 0) { // let barDescr = $('div[class^="tooltip"]').children('p[class^="bar-descr"]');
barDescr[0].childNodes.forEach(i => { // if (barDescr.length !== 0) {
if (tooltipDict[i.nodeValue]) i.nodeValue = tooltipDict[i.nodeValue]; // barDescr[0].childNodes.forEach(i => {
}) // if (tooltipDict[i.nodeValue]) i.nodeValue = tooltipDict[i.nodeValue];
} // })
let miniprof_tooltip = $("#body > div.ToolTipPortal > div > div:nth-child(2)"); // }
if (miniprof_tooltip.length !== 0) { // let miniprof_tooltip = $("#body > div.ToolTipPortal > div > div:nth-child(2)");
if (tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]) { // if (miniprof_tooltip.length !== 0) {
miniprof_tooltip[0].firstChild.nodeValue = tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]; // if (tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]) {
} // miniprof_tooltip[0].firstChild.nodeValue = tooltipDict[miniprof_tooltip[0].firstChild.nodeValue];
} else { // }
//todo 通配符匹配 // } else {
} // //todo 通配符匹配
}).observe(tooltip, {attributes: true, childList: true, subtree: true}); // }
};
if($('div.profile-mini-root').length>0)
miniprofTrans();
else {
const intervalInit = setInterval(() => {
const miniProfileFirst = $('div.profile-mini-root').get(0);
if(miniProfileFirst){
clearInterval(intervalInit);
miniprofTrans();
miniprofOB.observe(miniProfileFirst, {attributes: true, childList: true, subtree: true});
} }
}, 1000); }, 1000);
}
// let tooltip = $('div.ToolTipPortal')[0];
// let intervalID = setInterval(() => {
// tooltip = $('div.ToolTipPortal')[0];
// if (tooltip) {
// clearInterval(intervalID);
// new MutationObserver(mutations => {
// let barDescr = $('div[class^="tooltip"]').children('p[class^="bar-descr"]');
// if (barDescr.length !== 0) {
// barDescr[0].childNodes.forEach(i => {
// if (tooltipDict[i.nodeValue]) i.nodeValue = tooltipDict[i.nodeValue];
// })
// }
// let miniprof_tooltip = $("#body > div.ToolTipPortal > div > div:nth-child(2)");
// if (miniprof_tooltip.length !== 0) {
// if (tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]) {
// miniprof_tooltip[0].firstChild.nodeValue = tooltipDict[miniprof_tooltip[0].firstChild.nodeValue];
// }
// } else {
// //todo 通配符匹配
// }
// }).observe(tooltip, {attributes: true, childList: true, subtree: true});
// }
// }, 1000);
};
miniProfile();
/** /**
* header * header