请根据需要请手动调节setting参数
Pada tanggal
// ==UserScript==
// @name 咕咕镇样式优化,等级换算
// @namespace http://tampermonkey.net/
// @version 3.0.4
// @description 请根据需要请手动调节setting参数
// @author aotmd
// @match https://www.guguzhen.com/*
// @icon https://www.guguzhen.com/ys/icon/z4.gif
// @grant none
// ==/UserScript==
var setting = {
/*───开启为true,关闭为false────*/
等级换算: true ,/*是否开启等级换算*/
保留小数位: 1 ,/*转换后的等级显示的小数位*/
实际属性点计算: true ,/*根据实际属性点计算等级,通过转换计算产生的属性点带有小数,实际属性点会不带小数直接舍去*/
保留原等级: false ,/*保留转换前的等级*/
/*────────────────────────────*/
响应式布局: true ,/*是否开启按照浏览器宽度改变布局*/
相对宽度: 70 ,/*网页内容宽度占浏览器的百分比,单位:%*/
/*────────────────────────────*/
样式更改: true ,/*是否更改css样式*/
血条护盾高度: 14 ,/*单位:px*/
字体上下间距: 26 ,/*单位:px*/
};
/**
* 等级转换
* @param o 原等级
* @param q 品质
* @return {string}
*/
function ConversionLevel(o, q) {
const BIT = setting.保留小数位;
const ACTUAL = setting.实际属性点计算;
var point = (6 + o * 3) * (1 + q / 100);
if (ACTUAL) {
point = Math.floor(point);
}
return ((point - 6) / 3).toFixed(BIT);
}
setInterval(() => {
const ORIGINAL = setting.保留原等级;
var str = /fyg_equip\.php/i;
if (str.test(window.location.href) && setting.等级换算) {
var cardInformation = document.getElementsByClassName("text-info fyg_f24")[0]
.getElementsByClassName("pull-right")[0];
if (cardInformation.getAttribute("style") == null) {
var url = document.getElementsByClassName("text-info fyg_tr")[0];
var array = url.innerText.match(/\d+/g);
var maxRank = ConversionLevel(array[1], array[0]);
url.innerText += " 相当于" + maxRank + "级";
var nowRank = ConversionLevel(cardInformation.innerText.match(/\d+/g)[0], array[0]);
if (ORIGINAL) {
cardInformation.innerText += "(" + nowRank + " 级)";
} else {
cardInformation.innerText = nowRank + " 级";
}
cardInformation.style = "flag: 1;";
}
var otherCard = document.getElementsByTagName("h4");
if (otherCard.length !== 0 && otherCard[0].getAttribute("style") == null) {
for (var j = 0; j < otherCard.length; j++) {
var temp = otherCard[j].innerHTML;
var reg = new RegExp(/(\d+)( \/ )(\d+)(<br>.+\| )(\d+)/);
otherCard[j].innerHTML = temp.replace(reg, function () {
var args = arguments;
var nowRank = args[1];
var maxRank = args[3];
var quality = args[5];
var nowRank2 = ConversionLevel(nowRank, quality);
var maxRank2 = ConversionLevel(maxRank, quality);
var line = nowRank2 + " / " + maxRank2;
var result;
if (ORIGINAL) {
result = args[1] + args[2] + args[3] + "<br>Lv." + line + args[4] + args[5];
} else {
result = line + args[4] + args[5];
}
return result;
});
otherCard[j].style = "flag: 1;";
}
}
}
}, 1000);
/**
* 添加样式
* @param rules css样式
*/
function addStyle(rules) {
var styleElement = document.createElement('style');
styleElement.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(styleElement);
styleElement.appendChild(document.createTextNode(rules));
}
if (setting.响应式布局) {
addStyle(`
div[style='width:1200px;margin: 0 auto;'] {
width: ` + setting.相对宽度 + `%!important;
}
`);
}
if (setting.样式更改) {
addStyle(`
/*调整脚本:咕咕镇数据采集)*/
/*调整装备详情的对齐方式*/
button.btn.btn-light {
vertical-align: sub;
}
/*调整装备神秘属性文字的最大宽度*/
.bg-danger[style="max-width: 250px; white-space: pre-line; word-break: break-all;"]{
max-width: 200px!important;
}
/*改变战斗页面血条护盾的高度*/
.fyg_pvedt{
height: ` + setting.血条护盾高度 + `px!important;
}
/*改变战斗页面的间距*/
p.fyg_mp0.fyg_nw.fyg_lh30,p.fyg_mp0.fyg_nw.fyg_lh30.fyg_tr{
line-height: ` + setting.字体上下间距 + `px;
}
`);
}
/*下为历史数据,不生效*/
/*addStyle(`
#pkcall,#closeresult {
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
margin: 4px 10px;
width: 100px;
border-radius: 15px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
cursor: pointer;
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
#pkcall:hover,#closeresult:hover {
background-color: #4CAF50;
color: white;
}
div#result {
line-height: 1;
padding: 10px;
padding-bottom: 50px;
border: 2px solid transparent;
border-color: #9d15f3;
width: 100px;
text-align: center;
margin: 10px;
border-radius: 10px;
transition-duration: 1s;
}
div#result:hover {
background-color: #2ae23894;
border-color: #ffffff00;
}
`);*/
/*var b= document.getElementsByClassName("panel panel-primary")[0];
b.innerHTML = "<button id='pkcall'>导出怪兽数据</button>" + b.innerHTML;
var jsjfunction=function () {
var pk = document.getElementsByClassName("btn dropdown-toggle fyg_lh40");
var s = "<div id='result'>";
for (var i = 0; i < 10; ++i) {
var temp = pk[i].innerText.trim();
var name = temp.slice(-1);
var lv = temp.slice(temp.indexOf("Lv") + 2, temp.lastIndexOf(" "));
switch (name) {
case "人": name = "MU"; break;
case "蛛": name = "ZHU"; break;
case "灵": name = "DENG"; break;
case "兽": name = "SHOU"; break;
default : alert("erreo");
}
var parameter=name+" "+lv;
for (var j = 0; j <= 3; j++) {
s += "<div>" + parameter +" "+j+ "</div>";
}
}
s += "</div>";
b.innerHTML = s+"<button id='closeresult'>清除怪兽数据</button>" + b.innerHTML;
$("#pkcall").remove();
$("#closeresult").click(function(){
b.innerHTML = "<button id='pkcall'>导出怪兽数据</button>" + b.innerHTML;
$("#pkcall").click(jsjfunction);
$("#result").remove();
$("#closeresult").remove();
});
};
$(document).ready(function() {
$("#pkcall").click(jsjfunction);
});*/