Score-Tolerance

SDVX譜面保管所でS許容ニア数を、CHUNITHM譜面保管所でSSS許容アタ数(J別)を表示します。

目前為 2021-05-30 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Score-Tolerance
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  SDVX譜面保管所でS許容ニア数を、CHUNITHM譜面保管所でSSS許容アタ数(J別)を表示します。
// @description  (譜面保管所のデータを使用しているので、SDVXのデータは最新でない可能性があります)
// @author       null
// @include      /https:\/\/sdvx.in\/sort\/sort_[0-9].*/
// @include      /https:\/\/sdvx.in\/chunithm\/sort\/[0-9].*/
// @icon         
// @grant        none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
// ==/UserScript==

(function () {
  'use strict';

  function GetChain(ID, src) {
    const chain_check_text = 'CH' + ID;
    var chain = '';
    $.ajax({
      type: 'GET',
      url: src,
      dataType: "text",
      async: false,
    })
      .done(function (textall) {
        textall = textall.split('\n');
        for (const textdata of textall) {
          const check_text = textdata.slice(4, 12);
          if (check_text == chain_check_text) {
            let j = textdata.indexOf("CHAIN", 15) + 5;
            while (!(textdata[j - 1] == '>' && $.isNumeric(textdata[j])) && j < textdata.length) {
              j++;
            }
            while (textdata[j] != '<' && j < textdata.length) {
              chain += textdata[j];
              j++;
            }
            break;
          }
        }
      });
    return chain;
  }

  function CalcTolerance(chain, gametype) {
    if (gametype == 0) { // SDVX
      return Math.floor(chain / 50);
    } else if (gametype == 1) { // CHUNITHM
      let res = [];
      let t = Math.floor((2500 * chain) / 510000 * 10) / 10; // ATTACK
      res.push(t.toFixed(1));
      t = Math.floor(chain / 100);
      res.push(t);
      return res;
    }
  }

  window.onload = function () {
    const url = location.href;
    let gametype;
    const regex = new RegExp('https://sdvx.in/sort/*');
    if (regex.test(url)) gametype = 0;
    else gametype = 1;
    if (document.getElementById('extended') !== null) return;
    const html_idx = [[1, 7], [4, 2]];
    const start_index = [2, 2];
    const html0 = document.getElementsByTagName('center')[0].getElementsByClassName('c')[html_idx[0][gametype]].getElementsByClassName('tbg')[0];
    if (gametype == 0) {
      html0.getElementsByTagName('tbody')[0].insertAdjacentHTML('afterbegin', '<tr><td></td><td></td><td></td><td style="text-align:right;"><div class="f3">※最新でない恐れあり</div></td></tr>');
      html0.getElementsByTagName('tbody')[0].insertAdjacentHTML('afterbegin', '<tr><td></td><td></td><td></td><td style="text-align:right;"><div class="f1">S許容ニア数</div></td></tr>');
    } else {
      html0.getElementsByTagName('tbody')[0].insertAdjacentHTML(
        'afterbegin',
        '<tr><td></td><td><td style="text-align:right;"><div class="f2">SSS許容アタ数<br>(JUSTICE0の場合)</div></td>'
        + '<td style = "text-align:right;"><div class="f2">99AJ<br>許容(J)</div></td>'
      );
    }
    const html = html0.getElementsByTagName('tr');
    for (let i = start_index[gametype]; i < html.length; i++) {
      const td = html[i].getElementsByTagName('td');
      if (td.length <= 1) continue;
      const script_data = td[0].getElementsByTagName('script');
      const src = script_data[0].getAttribute('src');
      const ID = script_data[1].innerHTML.slice(4, 4 + 6);
      const chain = parseInt(GetChain(ID, src));
      if (isNaN(chain)) continue;
      if (gametype == 0) {
        td[html_idx[1][gametype]].insertAdjacentHTML('afterend', '<td style="text-align:right;"><div class="f1">' + CalcTolerance(chain, gametype) + '</div></td>');
      } else {
        const result = CalcTolerance(chain, gametype);
        td[html_idx[1][gametype]].insertAdjacentHTML(
          'afterend',
          '<td style="text-align:right;"><div class="f2">' + result[0] + '</div></td>'
          + '<td style="text-align:right;"><div class="f2">' + result[1] + '</div></td>'
        );
      }
    }
    document.getElementsByTagName('head')[0].setAttribute('id', 'extended');
  }

})();