// ==UserScript==
// @name 装备管理
// @namespace http://tampermonkey.net/
// @version 2025-12-16
// @description 别问这是什么
// @author 生猛的程序
// @match https://aring.cc/awakening-of-war-soul-ol/
// @icon https://www.google.com/s2/favicons?sz=64&domain=aliyuncs.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
let jsPath=''
const htmlStr={
divstr:`
`,
lcukHtml:``
}
//🔒
let btnstksp,btncrt,btnheat
let labstksp,labcrt,labheat
let btnlock,lockviews
let isAutoLock=false
let baseListData=[]
let special=[] //--筛选词条
let lastTime = 0;
const wait =200;
let buttons;
let clickfillertype=-1 //--排序条件
function fullView(){
const viewparent=document.querySelector('.item-page')
if(viewparent){
const childParent=viewparent.querySelector('.action');
if(childParent){
const pageview=childParent.querySelector('.item-filter-wrap');
if(pageview){
const oldbuttons = pageview.querySelectorAll('button');
oldbuttons.forEach(button=>{
// 创建MutationObserver监听样式变化
if(button.innerText==='重置'){
// 添加点击事件(可选)
button.addEventListener('click', () => {
clickfillertype=-1;
special=[];
baseListData=[];
( btnstksp && (btnstksp.style='margin-top: 10px;',labstksp.classList.remove('unique')),
btncrt && (btncrt.style='margin-top: 10px;',labcrt.classList.remove('unique')),
btnheat && (btnheat.style='margin-top: 10px;',labheat.classList.remove('unique')))
buttons.forEach(button => {
if(button.id){
const labBtn=document.getElementById(`lab${button.id}`)
button.style='margin-top: 10px;'
labBtn && labBtn.classList.remove('legend')
}
});
setTimeout(sortItemsByAtksp, 100);
console.log('重置按钮被点击');
});
}
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
const currentStyle = button.getAttribute('style') || '';
const hasRedBorder = currentStyle.includes('border-color: red');
// 触发自定义事件
const event = new CustomEvent('borderColorChange', {
detail: {
hasRedBorder: hasRedBorder,
element: button
}
});
button.dispatchEvent(event);
}
});
});
// 开始观察
observer.observe(button, {
attributes: true,
attributeFilter: ['style']
});
// 添加事件监听器
button.addEventListener('borderColorChange', (e) => {
//--先确认ID是否为排序相关
const now = Date.now();
if (now - lastTime >= wait) {
if (e.detail.hasRedBorder) {
console.log('按钮边框变为红色:', e.detail.element.id);
// 在这里添加边框变红时的处理逻辑
} else {
console.log('按钮边框红色消失:', e.detail.element.id);
// 在这里添加边框红色消失时的处理逻辑
}
lastTime = now;
baseListData=[];
setTimeout(sortItemsByAtksp, 100);
}
});
});
// 创建新元素
const newElement = document.createElement(`div`);
//newElement.className = 'common-btn-wrap';
newElement.setAttribute(childParent.attributes[0].name, '');
// newElement.setAttribute(`style`,"grid-column: span 3;width:100%;")
newElement.innerHTML = htmlStr.divstr;
// 添加点击事件(可选)
//pageview.appendChild(8,newElement);
pageview.insertBefore(newElement, pageview.children[9]);
// 为所有子元素设置属性
const allChildren = newElement.querySelectorAll('*');
allChildren.forEach(child => {
child.setAttribute(childParent.attributes[0].name, '');
});
// 监听button元素的样式变化
buttons = newElement.querySelectorAll('button');
buttons.forEach(button => {
const btnID=button.id
let clicktype=-1;
switch(btnID){
case 'btnstksp':
!btnstksp && (btnstksp=button,labstksp=document.getElementById('labstksp'))
clicktype=0
break
case 'btncrt':
!btncrt && (btncrt=button,labcrt=document.getElementById('labcrt'))
clicktype=1
break
case 'btnheat':
!btnheat && (btnheat=button,labheat=document.getElementById('labheat'))
clicktype=2
break
}
// if(clicktype>=0){
button.addEventListener('click', (e) => {
if(clicktype==-1){
//const btn = e.target; // 获取被点击的按钮
//const bID=btn.id;
const labBtn=document.getElementById(`lab${btnID}`)
const isHave=special.find(item=>item===btnID)
if(isHave){
special = special.filter(item => item !== btnID);
button.style='margin-top: 10px;'
labBtn.classList.remove('legend')
}else{
special.push(btnID)
button.style="margin-top: 10px;border-color: red;"
labBtn.classList.add('legend')
}
}else{
( btnstksp && (btnstksp.style='margin-top: 10px;',labstksp.classList.remove('unique')),
btncrt && (btncrt.style='margin-top: 10px;',labcrt.classList.remove('unique')),
btnheat && (btnheat.style='margin-top: 10px;',labheat.classList.remove('unique')))
switch(btnID){
case 'btnstksp':
clickfillertype=0
// btnstksp.+="border-color: red;"
btnstksp.style="margin-top: 10px;border-color: red;"
labstksp.classList.add('unique')
//!btnstksp && (btnstksp=e.detail.element)
// clicktype=0
break
case 'btncrt':
clickfillertype=1
labcrt.classList.add('unique')
btncrt.style="margin-top: 10px;border-color: red;"
// !btncrt && (btncrt=e.detail.element)
// clicktype=1
break
case 'btnheat':
clickfillertype=2
labheat.classList.add('unique')
btnheat.style="margin-top: 10px;border-color: red;"
// !btnheat && (btnheat=e.detail.element)
// clicktype=2
break
}
}
sortItemsByAtksp()
});
// }
});
}
// 创建新元素
const newElement = document.createElement(`span`);
/*
newElement.setAttribute('aria-disabled', 'true');
newElement.setAttribute('type', 'button');
newElement.setAttribute('class', 'el-button el-button--success el-button--small is-plain normal');
newElement.setAttribute(childParent.attributes[0].name, '');
*/
newElement.setAttribute(`style`,"margin-left: 12px;")
newElement.setAttribute('class', 'equip-lock');
newElement.innerHTML = htmlStr.lcukHtml;
btnlock=newElement.querySelector('button');
lockviews=newElement.querySelectorAll('.el-icon')
// 添加点击事件(可选)
newElement.addEventListener('click', () => {
// console.log('新按钮被点击',T);
if(isAutoLock){
//---解锁
btnlock.classList.remove('el-button--success');
btnlock.classList.add('el-button--info');
lockviews[0].style='font-size: 15px;'
lockviews[1].style='font-size: 15px; display: none;'
}else{
//---加锁
btnlock.classList.add('el-button--success');
btnlock.classList.remove('el-button--info');
lockviews[1].style='font-size: 15px;'
lockviews[0].style='font-size: 15px; display: none;'
setTimeout(LockItemsByAtksp, 2000);
}
isAutoLock=!isAutoLock
});
//pageview.appendChild(8,newElement);// 正确用法
childParent.insertBefore(newElement, childParent.children[childParent.children.length - 1]);
}
}
const htmlconet=document.create
}
setTimeout(fullView, 2000);
//---查找挂载JS
function findIndexJS(){
const scripts = document.querySelectorAll('script[src]');
scripts.forEach(script => {
const src = script.src;
if (src.includes('assets') && src.includes('index') && src.endsWith('.js')) {
jsPath=src;
loadData()
return
// console.log('找到目标文件:', src);
}
});
console.log('文件筛选完毕:');
}
setTimeout(findIndexJS, 2000);
let UserData
function loadData(){
if(!jsPath){
return;
}
if(!UserData){
const getModuleExports = async () => {
try {
const module = await import(jsPath); // 替换为实际路径
const data={};
data.userD=module.u;
return data;
} catch (e) {
console.error('模块加载失败:', e);
}
}
getModuleExports().then(tool => {
tool && (UserData=tool.userD,initData());
});
}
}
function initData(){
if(UserData){
const r=UserData()
baseListData=deepCopyArray(r.itemList)
}
}
function deepCopyArray(arr) {
return arr.map(item => {
if (Array.isArray(item)) {
return deepCopyArray(item);
} else if (typeof item === 'object' && item !== null) {
return { ...item };
} else {
return item;
}
});
}
function sortItemsByAtksp() {
if(UserData){
const r=UserData();
( !baseListData || baseListData.length==0) && initData();
const equippedList=[]
for (const [key, value] of Object.entries(r.equippedList)) {
//console.log(`装备类型: ${key}, ID: ${value}`);
equippedList.push(value);
}
const filterData =special.length==0?baseListData:baseListData.filter(item=>{
try{
return special.find(kv=>kv===item.darkGoldAttrs.special[0].key || kv===item.engraveAttr.special[0].key ) || equippedList.find(ql=>ql===item.id);
}catch(e){
return false
}
});
r.itemList=[]
const newList=clickfillertype>=0 ? filterData.sort((a, b) => {
const atkspA = getAtksp(a,clickfillertype) || 0;
const atkspB = getAtksp(b,clickfillertype) || 0;
return atkspB - atkspA; // 降序排序
}):filterData;
r.itemList=newList
}else{
loadData()
}
}
function getAtksp(item,typec) {
let findstr='atksp'
switch(typec){
case 0:
findstr='atksp';
break
case 1:
findstr='crt';
break
case 2:
findstr='heat';
break
}
const darkGoldAttrs = item.darkGoldAttrs || {};
const basicAttrs = darkGoldAttrs.basic || [];
if(typec>=0){
const crtdEntry = basicAttrs.find(attr => attr[0] === findstr);
return sumAttributes(basicAttrs,findstr)
}else{
//----加锁
const crtdValue = basicAttrs.find(attr => attr[1] === 10);
(crtdValue||hasSpecialValueGreaterThan5(item)) && (item.isLock =true);
}
}
function sumAttributes(basicAttrs, findstr) {
return basicAttrs.reduce((sum, attr) => {
if (attr[0] === findstr) {
return sum + attr[1];
}
return sum;
}, 0);
}
function hasSpecialValueGreaterThan5(item) {
const special = item.darkGoldAttrs?.special || [];
for (const attr of special) {
const data = attr.data || {};
for (const key in data) {
if (typeof data[key] === 'number' && data[key] > 5) {
return true;
}
}
}
return false;
}
//----加锁
function LockItemsByAtksp() {
if(UserData){
const r=UserData();
r.itemList.map(item=>getAtksp(item,-1));
}else{
loadData()
}
isAutoLock&&(setTimeout(LockItemsByAtksp, 2000));
}
})();