Greasy Fork

Soulforged Skill Decimals

Changes the skill level display to show decimal places

当前为 2020-10-01 提交的版本,查看 最新版本

// ==UserScript==
// @name        Soulforged Skill Decimals
// @description Changes the skill level display to show decimal places
// @version     1.1.3
// @include     *://soulforged.net:8443/*
// @include     *://soulforged.net/*
// @include     *://soulforged.westeurope.cloudapp.azure.com/*
// @include     *://soulsreforged.eastus.cloudapp.azure.com/*
// @include     *://play.soulforged.net/*
// @namespace   soulforged.net
// @grant       none
// @author      Zap
// ==/UserScript==

//assuming there is just the one
window.addEventListener("click", waitDecimalizeSkills);

function waitDecimalizeSkills() {
  //hope the DOM and all the required content is updated after a bit
  setTimeout(decimalizeSkills, 25);
}

function decimalizeSkills() {
  var indicators = document.getElementsByClassName("skill-indicator");
  
  //iterate all skill indicators
  for(var indicator of indicators) {
    //find the bar element and extract the fill percentage
    var width = indicator.getElementsByClassName("skill-meter")[0].getElementsByClassName("meter-clip")[0].style.width;
    var percentage = width.substring(0, width.length - 1); //eliminate percentage sign
    //determine base skill level from element style class
    var i = 0;
    while(true) {
      if(indicator.getElementsByClassName("skill-level")[0].classList.contains("skill-level-" + i)) {
        var skillLevel = i;
        break;
      }
      i++;
    }
    var skillDecimal = skillLevel + (percentage / 100);
    indicator.getElementsByClassName("skill-level")[0].innerHTML = skillDecimal.toFixed(3);
    indicator.getElementsByClassName("skill-level")[0].style.fontSize = "35%";
  }
}