Highlight Updates in History

Highlights Updates in history tab of Nexus Mods

安装此脚本
作者推荐脚本

您可能也喜欢Grab Mods Requiring Links

安装此脚本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Highlight Updates in History
// @namespace    http://tampermonkey.net/
// @version      2024-03-26
// @description  Highlights Updates in history tab of Nexus Mods
// @author       TragicNet
// @match        https://www.nexusmods.com/users/myaccount?tab=download+history
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nexusmods.com
// @grant       GM_addStyle
// ==/UserScript==

function updateDateColors(newColor, oldColor) {
    let tableRows = document.querySelectorAll('tbody > tr');
    tableRows.forEach((row) => {
        let dlDate = new Date(row.querySelector('td:nth-child(2)').innerHTML);
        let updateDate = new Date(row.querySelector('td:nth-child(5)').innerHTML);
        if(dlDate > updateDate) {
            row.querySelector('td:nth-child(2)').style.color = newColor;

        } else {
            row.querySelector('td:nth-child(2)').style.color = oldColor;
        }
    })
}


window.addEventListener('load', (event) => {
    // Select the node that will be observed for mutations
    const targetNode = document.getElementById("tab-my-download-history");

    // Options for the observer (which mutations to observe)
    const config = { childList: true, subtree: true };

    // Callback function to execute when mutations are observed
    const callback = (mutationList, observer) => {
        updateDateColors('cyan', 'red');
    };

    // Create an observer instance linked to the callback function
    const observer = new MutationObserver(callback);

    // Start observing the target node for configured mutations
    observer.observe(targetNode, config);
});