Project Zomboid

Project Zomboid

Not enough ratings
Automated: Workshop Collection
By paper ໒꒱· ゚
I hate it. Manually adding workshop items 1 by 1, as if I was a sweatshop worker.
Consider yourself lucky.

Fellow hosts and server configurers, I share with you 2 scripts that shall make your generous life a bit easier.
3
   
Award
Favorite
Favorited
Unfavorite
DISCLAIMER
1) I did not write the code. ChatGPT did. I only did some prompt engineering.
2) I do not know a single thing about javascript or Steam's API.
3) This guide was made on June 24, 2023. It might will become obsolete in the future.
PREREQUISITES
1) Workshop Collection (if you don't have one yet, create one here: https://gtm.steamproxy.vip/workshop/browse/?section=collections&appid=108600)

2) String of Workshop Items - most people do not use excel sheets like I did in the video. If you're one of those people who edits their server settings in-game, go to C:\Users\<YOUR USER NAME>\Zomboid\Server then open servertest.ini or whatever is the name of your server settings like customname.ini, open it with a text editor like notepad, notepad++ or visual studio code. search for "WorkshopItems=", you should be able to find your string of workshop items there.

3) Browser: Mozilla Firefox - I don't use Google Chrome, nor should you in all honesty. But then again, you could still use other browsers, I just don't know if the scripts will work for it. BE WARNED.
Workshop Collection - Add Items

Open up your browser, make sure you are logged in to Steam.
Go to your workshop collection and under Owner Controls, Click Edit Collection.
Now, you'll see "Select items to put in your collection". I'm not sure if you need to have "Subscribed Items" as the active tab or not but just do it for consistency's sake.


Now, open up your browser's console, if you use Mozilla Firefox then the hotkey for it is Ctrl+Shift+K.

Copy this code and paste it on your console:
// CHANGE THESE TO YOUR NEEDS // example: workshopIDs = "2169435993;566115016;2810800927"; var workshopIDs = ""; // you can get collection id from the url of your workshop collection, // example: gtm.steamproxy.vip/sharedfiles/filedetails/?id=2986523667 // collectionID = "2986523667"; var collectionID = ""; // CODE var workshopIDsArray = workshopIDs.split(";"); function addItemToCollection(collectionID, workshopID) { var divID = "choice_MySubscribedItems_" + workshopID; var choiceDiv = document.getElementById(divID); if (choiceDiv) { choiceDiv.click(); console.log("Added item " + workshopID + " to the collection."); } else { console.log("Item " + workshopID + " not found."); } } function addItemsToCollection(collectionID, workshopIDsArray) { var collectionItems = document.getElementsByClassName("collectionItem"); var existingWorkshopIDs = Array.from(collectionItems).map(function(item) { return item.getAttribute("data-publishedfileid"); }); workshopIDsArray.forEach(function(workshopID) { if (!existingWorkshopIDs.includes(workshopID)) { addItemToCollection(collectionID, workshopID); } else { console.log("Item " + workshopID + " is already in the collection."); } }); } addItemsToCollection(collectionID, workshopIDsArray);

Make sure to add your collectionID and workshopIDs in the code. If you don't know what I'm talking about, then watch the video about at around 20 seconds in.

After that then just press <Enter> on the console and watch as you save yourself from hours of labor. Done.

PLEASE NOTE: Some workshop items will fail to be added into the collection. Even if you won't be able to manually add it. That's just how some mods are. Those are mods that are set as unlisted in privacy. Some examples are Worse Vehicle Condition and TCCacheMP.
Workshop Collection - Remove All Items

This one's pretty straightforward. Just has similar steps to adding items except you don't need collectionID and workshopIDs. I'm not even sure why collectionID was needed for adding items lol.

Anyways, here's the code:

function clickAllDeleteButtons() {
var deleteButtons = document.getElementsByClassName("general_btn delete");

for (var i = 0; i < deleteButtons.length; i++) {
deleteButtons[i].click();
}
}

clickAllDeleteButtons();
15 Comments
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:31pm 
"I'm mostly curious how you told where you wanted to click when I'm assuming it didn't already know the structure of the steam page."

I'm not sure how you can workaround prompting to allow GPT to write a script for a webpage in all honesty, so I was actually the one who just gave it identifiers on what EXACTLY to click.
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:26pm 
From there I experimented with a bunch of things and finally came up with that last prompt.

Hope that helps!
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:26pm 
Now, to break it down, what happened here is first I had an idea of what must be done, which is "console script for Firefox that will use an input" . Then I provided it with an example of the input so that I don't have to explain to GPT HOW it should handle the input. Then I provided instructions of WHAT it should do with the input, and this what part is where it gets a bit experimental.

You'll have to first think in way how you yourself would add an item to a collection, and convert that to something the AI can understand. What I did here was use the Element Picker feature of Firefox (CTRL+Shift+C when you have Web Dev Tools activated through F12 or CTRL+Shift+I) and pick the element that I would click to add an item, which would be the "plus" icon. From there, I studied the structure of the web code and needed to find two things:
1) Something that uses its workshop ID
2) The class/ID of the div it is in
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:25pm 
With this prompt, GPT gave me (``` not included)
```
// Get the input string
var inputString = "2896041179;2169435993;2903860066;2991554892;2850135071;2529746725;2617575303;566115016;2810800927;2875394066;2842158398;2859296947";

// Split the input string into an array of IDs
var idArray = inputString.split(';');

// Iterate over each ID and click the corresponding element
idArray.forEach(function(id) {
// Construct the ID of the element to click
var elementId = "choice_MySubscribedItems_" + id;

// Find the element by ID
var element = document.getElementById(elementId);

// Check if the element exists before attempting to click
if (element) {
// Click the element
element.click();
console.log("Clicked element with ID: " + elementId);
}
});
```
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:25pm 
For the adding of items to collection, I've tried a couple of things, adding more and more detail that the AI didn't know about until I prompted

I want you to write a console script for Firefox that will use an input like "2896041179;2169435993;2903860066;2991554892;2850135071;2529746725;2617575303;566115016;2810800927;2875394066;2842158398;2859296947" and will click all div.ItemChoiceStatus of each div class=ItemChoice whose id is in the list of input. The id of each ItemChoice is something like "choice_MySubscribedItems_2878374713" so each ItemChoice div will have an id of "choice_MySubscribedItems_" + id.
paper ໒꒱· ゚  [author] 25 Dec, 2023 @ 9:24pm 
Hello @Tregan, I've already cleared out my prompt history so I won't be able to tell you exactly how it went, but I'll try prompting again to see how I can do something similar.

So, first things first, the workshop collection has had some QoL updates including deprecating the need for my clickAllDeleteButtons function, pretty nice. That means I won't be trying to prompt that one.

I'll be splitting my comment into parts since there is a 1000 character limit per comment.
Tregan 25 Dec, 2023 @ 3:48pm 
Hi friend, thanks for uploading. Would you be willing to share the GPT prompt and a little about your prompt writing process? I'm mostly curious how you told where you wanted to click when I'm assuming it didn't already know the structure of the steam page.
paper ໒꒱· ゚  [author] 1 Jul, 2023 @ 7:15am 
28 Maps, 7 Vehicle Packs, 82 Vehicles, A ton of items/building/clothing/etc, probably around 70-80, 9 Trait Mods, 100+ Gameplay/QoL, and 30+ Others.

All those mods and Brita's Weapons & Armors Pack takes up almost half of the total file size... Jesus.
Bombingham 1 Jul, 2023 @ 7:10am 
damn boi thats a lotta mods.
paper ໒꒱· ゚  [author] 1 Jul, 2023 @ 7:06am 
@Bombingham
Yea, for my server right now, we have at least 400+ mods, accumulating 9GB file size. We haven't included 10YL mod again yet, which will be an addition 3.4GB. Some of my friends have to reconnect like 2-4 times just to finish downloading everything.