-
Notifications
You must be signed in to change notification settings - Fork 0
/
nexus-mods-update-highlighter.js
42 lines (35 loc) · 1.53 KB
/
nexus-mods-update-highlighter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// ==UserScript==
// @name Nexus Mods Update Highlighter
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Highlight the "Last DL" column if it's older than the "Updated" column on Nexus Mods page
// @author pmcb
// @include https://*.nexusmods.com/*?tab=download+history
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Wait for the table to load
var checkExist = setInterval(function() {
var table = $('table.datatable');
if (table.length) {
clearInterval(checkExist);
// Get the index of the "Last DL" and "Updated" columns
var lastDLIndex = table.find('th:contains("Last DL")').index();
var updatedIndex = table.find('th:contains("Updated")').index();
// Loop through each row in the table
table.find('tbody tr').each(function() {
var row = $(this);
var lastDLCell = row.find('td:eq(' + lastDLIndex + ')');
var updatedCell = row.find('td:eq(' + updatedIndex + ')');
// Parse the date and time strings
var lastDLDate = new Date(lastDLCell.text());
var updatedDate = new Date(updatedCell.text());
// Compare dates and highlight if necessary
if (lastDLDate < updatedDate) {
lastDLCell.css('background-color', 'rgba(120, 0, 0, 1.0)');
}
});
}
}, 3000); // Check every 3 seconds for the table
})();