-
Notifications
You must be signed in to change notification settings - Fork 0
/
steam-game-feature-kai.user.js
73 lines (70 loc) · 3.04 KB
/
steam-game-feature-kai.user.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
65
66
67
68
69
70
71
72
73
// ==UserScript==
// @name Steam Game Feature Kai
// @namespace https://github.com/Vinfall/UserScripts
// @version 3.0.2
// @author Vinfall
// @match https://store.steampowered.com/app/*
// @grant none
// @license CC0 1.0 Universal (Public Domain)
// @description Alternative game feature outlinks on Steam store webpage
// @description:zh-cn Steam 商店页面游戏特性外链替换
// ==/UserScript==
(function () {
const appId = /app\/(\d+)\//.exec(location.href)?.pop();
if (appId) {
console.log(appId);
const warningColor = 'red';
var conditions = [
// Outlink replacement
{
srcIncludes: 'ico_achievements',
text: 'AStats',
href: 'https://astats.astats.nl/astats/Steam_Game_Info.php?AppID=' + appId
},
{
srcIncludes: 'ico_cloud',
text: 'Cloudsave',
href: 'https://store.steampowered.com/account/remotestorageapp?appid=' + appId + '&index=0'
},
{
srcIncludes: 'ico_cards',
text: 'Steam Card Exchange',
href: 'https://www.steamcardexchange.net/index.php?gamepage-appid-' + appId + '/'
},
{
srcIncludes: 'ico_workshop',
text: 'Workshop',
href: 'https://steamcommunity.com/workshop/browse/?appid=' + appId + '&browsesort=toprated§ion=readytouseitems'
},
// Warning on unexpected feature
{
// 'ico_cart' == IAP, 'ico_info` == profile features limited
srcIncludes: ['ico_coop', 'ico_multiPlayer', 'ico_cart', 'ico_vac', 'ico_info', 'ico_learning_about_game'],
color: warningColor
}
];
// TODO: expand to div.page_content > .game_meta_data.rightcol for better matching
var elements = document.querySelectorAll('a.game_area_details_specs_ctn');
elements.forEach(function (element) {
conditions.forEach(function (condition) {
if (Array.isArray(condition.srcIncludes)) {
if (condition.srcIncludes.some(src => element.querySelector('.icon img.category_icon').src.includes(src))) {
// Set color on unwanted feature
if (condition.color) {
element.querySelector('.label').style.color = condition.color;
element.querySelector('.label').style.fontWeight = 'bold';
}
}
} else {
// Replace outlink otherwise
if (element.querySelector('.icon img.category_icon').src.includes(condition.srcIncludes)) {
element.href = condition.href;
element.querySelector('.label').innerText = condition.text;
}
}
});
});
} else {
console.error('Unsupported URL');
}
})();