-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodListGenerator.user.js
78 lines (68 loc) · 2.51 KB
/
modListGenerator.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
74
75
76
77
78
// ==UserScript==
// @name Steam Workshop Collection WH3 Mod Manager List Generator
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Get a list of mod codes from a Steam Workshop collection page and return them as Shazbot WH3 mod manager list
// @author moodyswing
// @match https://steamcommunity.com/sharedfiles/filedetails/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var modList = document.getElementsByClassName("collectionItem");
var modCodes = "";
for (var i = 0; i < modList.length; i++) {
var modCode = modList[i].getAttribute("id");
if (modCode != null) {
modCodes += modCode.slice(11) + "|";
}
}
console.log(modCodes.slice(0, -1));
var button = document.createElement("button");
button.innerHTML = "Get WH3 Mod Manager mods list";
button.style.marginTop = "10px";
button.style.padding = "10px";
button.style.backgroundColor = "#4CAF50";
button.style.color = "white";
button.style.borderRadius = "5px";
button.style.border = "none";
button.style.cursor = "pointer";
var popup = document.createElement("div");
popup.style.display = "none";
popup.style.position = "fixed";
popup.style.zIndex = "1";
popup.style.left = "50%";
popup.style.top = "50%";
popup.style.transform = "translate(-50%, -50%)";
popup.style.width = "300px";
popup.style.height = "200px";
popup.style.backgroundColor = "#f1f1f1";
popup.style.borderRadius = "5px";
popup.style.padding = "20px";
var span = document.createElement("span");
span.innerHTML = "×";
span.style.position = "absolute";
span.style.top = "0";
span.style.right = "10px";
span.style.fontSize = "28px";
span.style.fontWeight = "bold";
span.style.cursor = "pointer";
var content = document.createElement("textarea");
content.innerHTML = modCodes.slice(0, -1);
button.onclick=function(){
navigator.clipboard.writeText(content.innerHTML);
alert("List copied to clipboard!\nPaste them into 'Share Mod List'->'Import'");
}
span.onclick=function(){
popup.style.display="none";
}
window.onclick=function(event){
if(event.target==popup){
popup.style.display="none";
}
}
var subscribeButtonDivs=document.getElementsByClassName("subscribeCollection");
if(subscribeButtonDivs.length>0){
subscribeButtonDivs[0].appendChild(button);
}
})();