Check the score of MixBots!
当前为
// ==UserScript==
// @license MIT
// @name MixMob MixBots Score
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Check the score of MixBots!
// @author ercalote
// @match https://magiceden.io/*
// @match https://www.magiceden.io/*
// @icon https://www.google.com/s2/favicons?domain=magiceden.io
// @grant GM_log
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function findParentWithDataIndex(element) {
if (!element) return null;
if (element.getAttribute('data-index') !== null) {
return element;
}
return findParentWithDataIndex(element.parentElement);
}
function createParagraph(text, score) {
var paragraph = document.createElement('p');
paragraph.textContent = text + ': ' + score;
return paragraph;
}
(function() {
'use strict';
let addedDivs = new Set();
function addDivAfterImage(image) {
if (!addedDivs.has(image)) {
var slug = (image.src.match(/SLUG/g) || []).length;
var huntr = (image.src.match(/HUNTR/g) || []).length;
var grnt = (image.src.match(/GRNT/g) || []).length;
var wzrd = (image.src.match(/WZRD/g) || []).length;
var lzrd = (image.src.match(/LZRD/g) || []).length;
var fink = (image.src.match(/FINK/g) || []).length;
var kng = (image.src.match(/KNG/g) || []).length;
var mnstr = (image.src.match(/MNSTR/g) || []).length;
var acceleration = 10 - slug + huntr + fink - kng;
var max_speed = 10 + slug - wzrd + lzrd - fink;
var durability = 10 - huntr + grnt + kng - mnstr;
var willpower = 10 - grnt + wzrd - lzrd + mnstr;
var factionMatch = image.src.match(/mixbots\/(.*?)_/);
var faction = factionMatch ? factionMatch[1] : null;
var parentDivWithDataIndex = findParentWithDataIndex(image);
if (parentDivWithDataIndex) {
var firstChildDiv = parentDivWithDataIndex.firstElementChild;
if (firstChildDiv) {
var newDiv = document.createElement('div');
newDiv.appendChild(createParagraph('Faction', faction));
newDiv.appendChild(createParagraph('Acceleration', acceleration));
newDiv.appendChild(createParagraph('MaxSpeed', max_speed));
newDiv.appendChild(createParagraph('Durability', durability));
newDiv.appendChild(createParagraph('Willpower', willpower));
firstChildDiv.lastElementChild.appendChild(newDiv);
}
}
addedDivs.add(image);
}
}
function processImages() {
const images = document.querySelectorAll('img');
for (var i = 0; i < images.length; i++) {
if (images[i].src.includes('mixbot')) {
addDivAfterImage(images[i]);
}
}
}
setInterval(processImages, 200);
})();