Skip to content

Commit 445e62d

Browse files
committed
Add a progress bar to the discovery queue handler.
1 parent 3847972 commit 445e62d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

SteamDiscoveryQueueAutoSkipper.user.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,62 @@ function click (obj)
6161

6262
// Main queue-skipper
6363

64+
function injectLoadingBarStyleSheet()
65+
{
66+
let styleBg = '', styleAppendix = '';
67+
switch ((new Date()).getMonth())
68+
{
69+
case 11:
70+
styleBg =
71+
`background-size: 424px;
72+
background-image: repeating-linear-gradient(45deg, #ff0000, #af0000 13px, #1d6a00 6px, #1d4a00 30px);
73+
animation: moveGradient 5s linear infinite;`;
74+
styleAppendix =
75+
`@keyframes moveGradient {
76+
0% {
77+
background-position: 0 0; /* Start position */
78+
}
79+
100% {
80+
background-position: -424px 0; /* End position */
81+
}
82+
}`;
83+
break;
84+
default:
85+
styleBg =
86+
`background-color: #ffcc6a;`;
87+
}
88+
89+
const style = document.createElement('style');
90+
style.innerHTML = `#queueActionsCtn::after {
91+
content: '';
92+
position: absolute;
93+
top: 0;
94+
left: 0;
95+
width: 0px;
96+
transition: width 1s ease 0s;
97+
height: 100%;
98+
${styleBg}
99+
}
100+
${styleAppendix}`;
101+
document.getElementsByTagName('head')[0].appendChild(style);
102+
return style.sheet.cssRules;
103+
}
104+
105+
const loadingBarAfterStyle = Array.from(injectLoadingBarStyleSheet()).filter(rule => rule.selectorText === "#queueActionsCtn::after").map(rule => rule.style)[0];
106+
107+
function setLoadingBarProgress(percent) {
108+
if (loadingBarAfterStyle && isFinite (percent))
109+
loadingBarAfterStyle.width = Math.floor (Math.max (0, Math.min (100, percent))) + "%";
110+
}
111+
112+
const queueCountTotal = Number(document.getElementsByClassName("queue_sub_text")[0]?.textContent.match(/\d+/)[0] || 0);
113+
64114
function handleQueuePage()
65115
{
116+
const queueCountRemaining = Number(document.getElementsByClassName("queue_sub_text")[0]?.textContent.match(/\d+/)[0] || 0);
117+
const progress = 100 * (queueCountTotal-queueCountRemaining) / queueCountTotal;
118+
setLoadingBarProgress (progress);
119+
66120
var btn = document.getElementsByClassName ("btn_next_in_queue")[0];
67121

68122
if (btn)

0 commit comments

Comments
 (0)