forked from masterofobzene/UserScriptRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteam_Block_Games.user.js
More file actions
102 lines (79 loc) · 2.5 KB
/
Copy pathSteam_Block_Games.user.js
File metadata and controls
102 lines (79 loc) · 2.5 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ==UserScript==
// @name Steam Search Block Games
// @namespace Steam_Search_Block_Games
// @version 1.1
// @author masterofobzene
// @description Block button to hide individual games.
// @match https://store.steampowered.com/search/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @run-at document-end
// @license GNU GPLv3
// @icon https://store.steampowered.com/favicon.ico
// @downloadURL https://github.com/masterofobzene/UserScriptRepo/raw/main/SFW/Steam_Block_Games.user.js
// @updateURL https://github.com/masterofobzene/UserScriptRepo/raw/main/SFW/Steam_Block_Games.user.js
// ==/UserScript==
(function() {
'use strict';
let hidden = GM_getValue('hiddenGames', {});
const save = () => GM_setValue('hiddenGames', hidden);
function hideBlocked() {
document.querySelectorAll('[data-ds-appid]').forEach(row => {
if (hidden[row.dataset.dsAppid]) row.style.display = 'none';
});
}
function addButtons() {
document.querySelectorAll('[data-ds-appid]:not(.block-btn-added)').forEach(row => {
row.classList.add('block-btn-added');
const id = row.dataset.dsAppid;
if (!id || hidden[id]) return;
const btn = document.createElement('button');
btn.textContent = 'Block';
btn.title = 'Block this game';
btn.style.cssText = `
cursor:pointer;
font-size:11px;
padding:2px 6px;
background:#a00;
color:#fff;
border:none;
border-radius:2px;
position:absolute;
right:100px;
top:20px;
z-index:5;
`;
btn.onclick = e => {
e.preventDefault();
e.stopPropagation();
const name = row.querySelector('.title')?.textContent.trim() || 'Unknown';
hidden[id] = name;
save();
row.style.display = 'none';
};
row.style.position = 'relative';
row.appendChild(btn);
});
}
const observer = new MutationObserver(() => {
hideBlocked();
addButtons();
});
observer.observe(document.body, { childList: true, subtree: true });
function tryAdd() {
hideBlocked();
addButtons();
}
tryAdd();
setTimeout(tryAdd, 1000);
setTimeout(tryAdd, 2500);
setTimeout(tryAdd, 4000);
GM_registerMenuCommand('Unblock All', () => {
if (confirm('Unblock all?')) {
hidden = {};
save();
location.reload();
}
});
})();