KF2 Server: Bookmarklet to Grab Workshop Map IDs
Adding many workshop maps to a Killing Floor 2 dedicated server by hand means copying every item ID and typing map names. This community tool, a JavaScript bookmarklet, builds those lines for you from any Steam Workshop page that lists items, so you can paste them straight into the server config.
How to use it
- Copy the minified bookmarklet below and save it as a bookmark in your browser (the bookmark's URL is the code).
- Open any Steam Workshop page that lists workshop items. The original gives your own workshop files page as an example, with a numperpage parameter such as 30.
- Click the bookmark.
- A dialog asks whether to print the output in the developer console. If you are unsure, answer Cancel: the list then replaces the current page.
- Copy the first list into
PCServer-KFEngine.ini. - Copy the second list into
PCServer-KFGame.ini.
For the config layout and how workshop items are subscribed on the server, see Dedicated server with workshop and SteamCMD.
What it outputs
For every workshop link on the page that has a title, the script prints:
- A section for
PCServer-KFEngine.ini: lines of the formServerSubscribedWorkshopItems=<id>with the item title as a comment. - A section for
PCServer-KFGame.ini: a block per map in the form[<title> KFMapSummary]withMapName=<title>.
Bookmarklet (minified)
javascript:var gameString="ServerSubscribedWorkshopItems=",URIS=[];jQuery("a").each(function(){var URI=jQuery(this).attr("href"),title=jQuery(this).find(".workshopItemTitle").text();-1!=URI.search(/filedetails\/\?id=[0-9]+/i)&&""!=title&&URIS.push({URI:gameString+URI.substr(URI.search(/\d{4}\d+/i)),TITLE:title})}),window.confirm("Output in developer console? (If not, list will replace current page!)")?(console.log("// Start of section going into PCServer-KFEngine.ini:\n\n"),URIS.forEach(function(item,index){console.log(item.URI+" // "+item.TITLE)}),console.log("// End of PCServer-KFEngine.ini section!\n\n"),console.log("// Start of section going into PCServer-KFGame.ini:\n\n"),URIS.forEach(function(item,index){console.log("["+item.TITLE+" KFMapSummary]"),console.log("MapName="+item.TITLE+"\n")}),console.log("\n\n// End of PCServer-KFEngine.ini section!\n\n")):(document.write("// Start of section going into PCServer-KFEngine.ini:<br/><br/>"),URIS.forEach(function(item,index){document.write(item.URI+" // "+item.TITLE+"<br/>")}),document.write("<br/><br/>// End of PCServer-KFEngine.ini section!<br/><br/>"),document.write("// Start of section going into PCServer-KFGame.ini:<br/><br/>"),URIS.forEach(function(item,index){document.write("["+item.TITLE+" KFMapSummary]<br/>"),document.write("MapName="+item.TITLE+"<br/><br/>")}),document.write("// End of PCServer-KFEngine.ini section!<br/><br/>"));
Readable version
var gameString = 'ServerSubscribedWorkshopItems=';
var URIS = [];
jQuery('a').each(function () {
var URI = jQuery(this).attr("href");
var title = jQuery(this).find('.workshopItemTitle').text();
if (URI.search(/filedetails\/\?id=[0-9]+/i) != -1 && title != "") {
URIS.push({ URI: gameString + URI.substr(URI.search(/\d{4}\d+/i)), TITLE: title });
}
});
if (window.confirm("Output in developer console? (If not, list will replace current page!)")) {
console.log('// Start of section going into PCServer-KFEngine.ini:\n\n');
URIS.forEach(function (item) { console.log(item.URI + " // " + item.TITLE); });
console.log('// End of PCServer-KFEngine.ini section!\n\n');
console.log('// Start of section going into PCServer-KFGame.ini:\n\n');
URIS.forEach(function (item) {
console.log('[' + item.TITLE + " KFMapSummary]");
console.log('MapName=' + item.TITLE + '\n');
});
} else {
// same output written into the page with document.write(...)
}
Tips
- The bookmarklet relies on jQuery, which Steam pages already load.
- Check the map names it prints: they are taken from the workshop titles, which may differ from the actual map file names. Fix them by hand if the server does not recognise a map.
- Only maps you want in the rotation need a KFMapSummary entry; keep the list tidy.
FAQ
- Where do the generated lines go?
- The first list (ServerSubscribedWorkshopItems) goes into PCServer-KFEngine.ini and the second list (KFMapSummary sections with MapName) goes into PCServer-KFGame.ini.
- Which pages does the bookmarklet work on?
- Any Steam Workshop page listing workshop items, such as a collection page or your own workshop files page.