-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackpacktflastseenhighlighter.js
64 lines (56 loc) · 2.97 KB
/
backpacktflastseenhighlighter.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ==UserScript==
// @name Backpack.tf Last Seen Highlighter
// @namespace https://github.com/JayBoom/Backpack.tf-Last-Seen-Highlighter
// @version 1.1
// @description Highlight last seen entries in Backpack.tf based on their recency
// @author JayTuut
// @match https://backpack.tf/*
// @grant none
// @homepageURL https://github.com/JayBoom/Backpack.tf-Last-Seen-Highlighter
// @supportURL https://github.com/JayBoom/Backpack.tf-Last-Seen-Highlighter/issues
// @downloadURL https://raw.githubusercontent.com/JayBoom/Backpack.tf-Last-Seen-Highlighter/main/backpacktflastseenhighlighter.js
// ==/UserScript==
(function() {
'use strict';
// Get all the result containers
var results = document.querySelectorAll('.result');
// Iterate over each result container
results.forEach(function(result) {
// Get all the descriptions within this result container
var descriptions = result.querySelectorAll('.description');
// Initialize a flag to determine if a recent time period was found
var isRecent = false;
// Iterate over each description in this result container
descriptions.forEach(function(description) {
// Get the text content of the description
var descriptionText = description.textContent.toLowerCase();
// Check if the description contains keywords indicating recency
if ((descriptionText.includes('days') ||
descriptionText.includes('1 month ago') ||
descriptionText.includes('2 months ago') ||
descriptionText.includes('week'))) {
// If the description indicates recency, set the flag to true
isRecent = true;
} if (descriptionText.includes('4 months ago') ||
descriptionText.includes('3 months ago') ||
descriptionText.includes('5 months ago') ||
descriptionText.includes('6 months ago') ||
descriptionText.includes('7 months ago') ||
descriptionText.includes('8 months ago') ||
descriptionText.includes('9 months ago') ||
descriptionText.includes('10 months ago') ||
descriptionText.includes('11 months ago') ||
descriptionText.includes('year') ||
descriptionText.includes('no known previous owner') ||
descriptionText.includes('12 months ago')) {
// If the description contains a keyword indicating a long time period, reset the flag to false
isRecent = false;
}
});
// If a recent time period was found in any of the descriptions within this result container
// and no long time period was found, highlight the container
if (isRecent) {
result.style.backgroundColor = 'lightgreen';
}
});
})();