简单搜索了一下……同盟内貌似没有相关的油猴脚本,所以就发了
作为一个新人,总是会在意积分数到底多少了,虽然知道计算公式,但是每次计算都有点麻烦。
在新手区看到【说起来积分应该如何查看】这个帖子后就有了想法,因此写了这个脚本
第一次在综合事务区发帖,看了下版规应该可以发的吧
如果有违规的地方请告诉我
这里要感谢一下 @367ddd 佬的代码补充建议还有 @哥特的亡零 的bug反馈以及投到综合事务区的建议
代码如下:
// ==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<nei_rong_shu_box.length;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<jie_cao_shu_box.length;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<jie_cao_shu_box.length;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();
};
})();
使用方法:浏览器安装油猴插件,在里面选择添加新脚本,将上述代码全部复制覆盖到里面即可,启用后正常的话应该能在个人页面看到积分,点进别人的页面好像也能看到
效果图:
本人代码菜鸟,如果有大佬有修改建议或者想直接在此基础上修改放出代码的,十分欢迎