好像成功了用浅薄的js编程能力写了个油猴脚本
把代码放出来好了(js大佬轻喷)
// ==UserScript==
// @name SS同盟积分计算
// @namespace https://sstm.moe/profile/
// @version 1.0
// @description 简单计算积分
// @author FuRobert
// @match *://sstm.moe/profile/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=sstm.moe
// @grant none
// ==/UserScript==
(function() {
'use strict';
let is_ok = false;
function calculator(){
let nei_rong_shu = 0;
let jie_cao_shu = 0;
let fu_yuan_shu = 0;
var nei_rong_shu_box = document.getElementsByClassName("ipsType_minorHeading");
for(let i=0; i<3;i++ ){
let temp_text = nei_rong_shu_box[i].parentElement.innerText;
if(temp_text.includes(',')){
temp_text=temp_text.replace(',',"");
}
if(temp_text.includes('内容数')){
nei_rong_shu = parseInt(temp_text.replace('内容数\n',""));
console.log(nei_rong_shu);
break;
}
}
var jie_cao_shu_box = document.getElementsByClassName("ipsDataItem_main");
if (jie_cao_shu_box[0] != null){
for(let i=0; i<5;i++ ){
let temp_text = jie_cao_shu_box[i].textContent;
if(temp_text.includes(',')){
temp_text=temp_text.replace(',',"");
}
if(temp_text.includes('J')){
jie_cao_shu = parseInt(temp_text.replace('J',""));
console.log(jie_cao_shu);
break;
}
}
for(let i=0; i<5;i++ ){
let temp_text = jie_cao_shu_box[i].textContent;
if(temp_text.includes(',')){
temp_text=temp_text.replace(',',"");
}
if(temp_text.includes('F')){
fu_yuan_shu = parseInt(temp_text.replace('F',""));
console.log(fu_yuan_shu);
break;
}
}
var box = document.getElementsByClassName("ipsDataList ipsDataList_reducedSpacing cProfileFields")[1];
var temp_box = box.children[0].cloneNode(true);
temp_box.children[0].children[0].innerHTML='积分';
temp_box.children[1].innerHTML = String((nei_rong_shu*0.3 + jie_cao_shu*0.03 + fu_yuan_shu*10).toFixed(2));
box.append(temp_box);
jie_cao_shu_box = document.getElementsByClassName("ipsDataItem_generic ipsDataItem_size3 ipsType_break");
for (let temp of jie_cao_shu_box){
console.log(temp.textContent);
if(temp.textContent.includes('积分')){
is_ok = true;
return;
}
}
}else{
if(is_ok == false){
setTimeout(start, 200);
}
return;
}
}
function start(){
if(is_ok == false){
setTimeout(calculator, 200);
}
}
window.onload=function(){
start();
};
})();
要使用的话,安装油猴插件,在里面选择添加新插件,把代码都复制进去然后启用应该就好了()
不过只是在我这边用着看起来挺正常,别人用不知道怎么样,手机端应该不行,要是哪天个人页面更新了点什么改了下布局可能就失效了
-----------------分割线-----------------
感谢 @367ddd 大佬给的修改建议,现在对于千位以上带逗号(如1,000)的数值会自动去掉逗号了