Skip to content

Instantly share code, notes, and snippets.

@JemiloII
Last active July 10, 2020 17:28
Show Gist options
  • Save JemiloII/fe0a5b7d7b62096090fb38f7d6e42e67 to your computer and use it in GitHub Desktop.
Save JemiloII/fe0a5b7d7b62096090fb38f7d6e42e67 to your computer and use it in GitHub Desktop.
Update AoH Modlist Collection.
/*
Run this script on
https://steamcommunity.com/sharedfiles/managecollection/?id=2033309240
*/
const bulklist = `
`;
const list = bulklist.split(/\n/).filter(a => a !== '').map(a => a.trim());
function createCollection(modList) {
const g_id = document.getElementById('id').value;
const g_appid = '244850';
function addMod(id, index, array) {
try {
const url = 'https://steamcommunity.com/sharedfiles/addchild';
const options = {
method: 'post',
postBody: 'id=' + g_id + '&sessionid=' + g_sessionID + '&childid=' + id + '&ajax=true',
onSuccess() {
console.log('Added mod', id);
if ((array.length - 1) === index) {
setTimeout(() => console.log('Mod List Collection Completed!'), 0);
}
}
};
new Ajax.Request(url, options);
} catch (e) {
console.error('Failed to add', id, e);
}
}
function removeMod(id, index, array) {
try {
const url = 'https://steamcommunity.com/sharedfiles/removechild';
const options = {
method: 'post',
postBody: 'id=' + g_id + '&sessionid=' + g_sessionID + '&childid=' + id + '&ajax=true',
onSuccess() {
console.log('Remove mod', id);
if ((array.length - 1) === index) {
setTimeout(() => console.log('Mod List Collection Completed!'), 0);
}
}
};
new Ajax.Request(url, options);
} catch (e) {
console.error('Failed to remove', id, e);
}
}
function subMod(id, index, array) {
try {
const url = 'https://steamcommunity.com/sharedfiles/subscribe';
const options = {
method: 'post',
postBody: 'id=' + g_id + '&appid=' + g_appid + '&sessionid=' + g_sessionID + '&childid=' + id + '&ajax=true',
onSuccess() {
console.log('Subbed mod', id);
addMod(id, index, array);
}
};
new Ajax.Request(url, options);
} catch (e) {
console.error('Failed to sub', id, e);
}
}
document
.querySelectorAll('.managedCollectionItem')
.forEach((item, index, array) => {
return removeMod(Number(item.id.replace('sharedfile_', '')));
});
modList.forEach(subMod);
}
createCollection(list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment