Skip to content

Commit f4cdb16

Browse files
committed
Update [SteamHunters] Tweaks.user.js
1 parent 7aaa638 commit f4cdb16

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

user.js/[SteamHunters] Tweaks.user.js

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
// @license GPL-3.0 License
88
// @tag kevingrillet
99
// @tag steamhunters.com
10-
// @version 1.0.3
10+
// @version 1.0.4
1111

1212
// @homepageURL https://github.com/kevingrillet/Userscripts/
1313
// @supportURL https://github.com/kevingrillet/Userscripts/issues
1414
// @downloadURL https://raw.githubusercontent.com/kevingrillet/Userscripts/main/user.js/[SteamHunters]%20Tweaks.user.js
1515
// @updateURL https://raw.githubusercontent.com/kevingrillet/Userscripts/main/user.js/[SteamHunters]%20Tweaks.user.js
1616

17+
// @match https://steamhunters.com/id/*/games*
1718
// @match https://steamhunters.com/id/*/apps/*/achievements
1819
// @icon https://www.google.com/s2/favicons?sz=64&domain=steamhunters.com
1920
// @grant GM_getValue
@@ -77,23 +78,56 @@
7778
}
7879
}
7980

81+
function addDateInfo() {
82+
const breadcrumb = document.querySelector('.breadcrumb');
83+
if (breadcrumb && !document.getElementById('date-info')) {
84+
const date = new Date();
85+
const year = date.getFullYear();
86+
const week = getWeekNumber(date);
87+
88+
const dateInfoTemplate = `
89+
<li id="date-info" class="pull-right" style="margin-left: auto;">
90+
<span class="text-muted">${year} - W${week}</span>
91+
</li>
92+
`.trim();
93+
94+
breadcrumb.insertAdjacentHTML('beforeend', dateInfoTemplate);
95+
}
96+
}
97+
98+
function getWeekNumber(date) {
99+
const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
100+
const daysSinceFirstDay = Math.floor((date - firstDayOfYear) / (24 * 60 * 60 * 1000));
101+
return Math.ceil((daysSinceFirstDay + firstDayOfYear.getDay() + 1) / 7);
102+
}
103+
104+
function isAchievementsPage() {
105+
return window.location.pathname.includes('/apps/') && window.location.pathname.includes('/achievements');
106+
}
107+
80108
// Observer for dynamic content
81109
const observer = new MutationObserver((mutations) => {
82110
for (const mutation of mutations) {
83111
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
84-
initButton();
85-
applyFilter();
112+
if (isAchievementsPage()) {
113+
initButton();
114+
applyFilter();
115+
}
116+
addDateInfo();
86117
}
87118
}
88119
});
89120

90121
// Start observing
91-
const targetNode = document.querySelector('.achievements');
122+
const targetNode = document.querySelector('.achievements') || document.querySelector('.breadcrumb');
92123
if (targetNode) {
93124
observer.observe(targetNode, { childList: true, subtree: true });
94125
}
95126

96127
// Initial setup
97-
initButton();
98-
applyFilter();
128+
if (isAchievementsPage()) {
129+
initButton();
130+
applyFilter();
131+
}
132+
addDateInfo();
99133
})();

0 commit comments

Comments
 (0)