Rate Your Music - % / Yes / Hold / No / Comments

Improves the way RYM displays information on profile updates pending approval by a moderator.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Rate Your Music - % / Yes / Hold / No / Comments
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Improves the way RYM displays information on profile updates pending approval by a moderator.
// @author       You
// @match        https://rateyourmusic.com/artist/profile_history*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rateyourmusic.com
// @license      MIT
// @grant        none
// ==/UserScript==

// set interval that will be used to check if the page is loaded
// useQuerySelectorAll('tr') if length is 1, then the page is not fully loaded
// if length is 2 or more, then the page is fully loaded
// if the page is fully loaded, then get the data
//

var interval = setInterval(function() {
    if (document.querySelectorAll('tr').length > 1) {
        clearInterval(interval);
        getData();
    }
}, 100);

function getData() {
    const rows = document.querySelector('.mbgen').querySelectorAll('tr');

    rows.forEach((row) => {
        const voteCell = row.querySelectorAll('td')[7];
        const voteData = voteCell?.innerText;

        if (voteData) {
            const commentInfo = voteData.match(/\/\/.+/)?.[0];

            const percent = voteData.split('|')[0]?.match(/\d+/)?.[0];
            const values = voteData.split('|').slice(1).map((_) => _.match(/\d+/)[0].trim());
            const yes = values[0];
            const hold = values[1];
            const no = values[2];
            const comments = values[3];

            let color = 'purple';

            if (Number(yes) >= 1 && percent >= 75) {
                color = 'green';
            } else if (Number(no) >= 1 && percent <= 40) {
                color = 'red';
            }

            const newData = `${percent ?? 0}%; Yes: ${yes}; No: ${no}; Hold: ${hold}; Comments: ${comments}; ${commentInfo}`;
            console.log({ newData });

            voteCell.innerHTML = newData;
        }
    })
}