Skip to content

Instantly share code, notes, and snippets.

@Rudokhvist
Forked from Ne3tCode/README.MD
Created October 12, 2020 08:48
Show Gist options
  • Save Rudokhvist/0f0ac3ee8ba4a66dc13aa716d3bf16e0 to your computer and use it in GitHub Desktop.
Save Rudokhvist/0f0ac3ee8ba4a66dc13aa716d3bf16e0 to your computer and use it in GitHub Desktop.
Community Pillar

Community tasks

  • View a broadcast
  • Add a game to your wishlist (Ricochet)
  • Rate an item on the Workshop (random TF2 map upvote)
  • Subscribe to an item in the Steam Workshop (subscribe + unsubscribe)
  • Set an avatar on your Community profile (not changed)
  • Set your real name on your Community profile (same as profile name)
  • Set a profile background (not changed)
  • Join a group (Steam Trading Cards Group)
  • Comment on a friend's profile (own profile)
  • Rate up content in your Activity Feed
  • Post a status to your friends (post + remove)
  • Feature a badge on your profile (Community badge)
  • Search the Steam Discussions

Usage

  1. Log into Steam Community via browser
  2. Open Community badge page
  3. Open Developer tools (F12)
  4. Copy-paste the code
  5. Press <Enter>
  6. Enjoy!
'use strict';
(function() {
var pathMatch = window.location.pathname.match(/^\/((?:id|profiles)\/[^\/]+)\/badges\/(\d+)/);
if (window.location.hostname !== 'steamcommunity.com' || !pathMatch || pathMatch[2] != '2') {
window.location.href = 'https://steamcommunity.com/my/badges/2';
return;
}
if (!g_steamID) {
alert('You are not logged in!');
return;
}
var k_ExpectedTasksCount = 28;
var g_ProfilePath = pathMatch[1];
var g_SteamTasks = $J('.badge_task');
if (g_SteamTasks.length != k_ExpectedTasksCount) {
console.error('Expected tasks ' + k_ExpectedTasksCount + ', but found ' + g_SteamTasks.length);
console.error('Stopped');
return;
}
var g_TasksQueue = [];
var bTaskBroadcast = isTaskAvailable(3);
var bTaskGameWishlist = isTaskAvailable(5);
var bTaskWorkshopRate = isTaskAvailable(11);
var bTaskWorkshopSubscribe = isTaskAvailable(12);
var bTaskWorkshop = bTaskWorkshopRate || bTaskWorkshopSubscribe;
var bTaskCommunityProfileRealName = isTaskAvailable(15);
var bTaskCommunityProfile = bTaskCommunityProfileRealName || isTaskAvailable(14) || isTaskAvailable(16);
var bTaskJoinGroup = isTaskAvailable(17);
var bTaskProfileComment = isTaskAvailable(18);
var bTaskFeedRateUp = isTaskAvailable(19);
var bTaskPostStatus = isTaskAvailable(20);
var bTaskSelectBadge = isTaskAvailable(23);
var bTaskDiscussionsSearch = isTaskAvailable(25);
function isTaskAvailable(task_id) {
var task = g_SteamTasks.eq(task_id);
if (!task.length)
return false;
return task.find('.quest_icon').attr('src').indexOf('_off') != -1;
}
function DoTaskBroadcast(next) {
$J.get('//steamcommunity.com/apps/allcontenthome?appHubSubSection=13').done(function(data) {
// first available broadcast
var match = data.match(/watch\/(\d+)/);
if (!match) {
console.error('[DoTaskBroadcast] Fail! (2)');
return next();
}
$J.get('//steamcommunity.com/broadcast/getbroadcastmpd/', {
steamid: match[1],
broadcastid: 0,
viewertoken: 0,
sessionid: g_sessionID
}).done(function(data) {
if (data.success !== 'ready') {
console.error('[DoTaskBroadcast] Fail! (4)');
} else {
console.log('[DoTaskBroadcast] OK!');
}
}).fail(function() {
console.error('[DoTaskBroadcast] Fail! (3)');
}).always(function() {
next();
});
}).fail(function() {
console.error('[DoTaskBroadcast] Fail! (1)');
next();
});
}
function DoTaskGameWishlist(next) {
$J.post('//steamcommunity.com/actions/AddToWishlist', {
sessionid: g_sessionID,
appid: 60 // Ricochet
}).done(function(data) {
if (data.success) {
console.log('[DoTaskGameWishlist] OK!');
} else {
console.error('[DoTaskGameWishlist] Fail! (2)');
}
}).fail(function() {
console.error('[DoTaskGameWishlist] Fail! (1)');
}).always(function() {
next();
});
}
function DoTaskWorkshop(next) {
$J.get('//steamcommunity.com/workshop/browse/', {
appid: 440,
browsesort: 'totaluniquesubscribers'
}).done(function(data) {
var matches = data.match(/sharedfile_(\d+)/g);
if (!matches) {
console.error('[DoTaskWorkshop] Fail! (2)');
return next();
}
var file_id = matches[Math.floor(Math.random() * matches.length)].substr(11);
var isDone = false;
if (bTaskWorkshopRate) {
console.log('[DoTaskWorkshop] Upvoting id#' + file_id);
$J.post('//steamcommunity.com/sharedfiles/voteup', {
id: file_id,
sessionid: g_sessionID
}).done(function(data) {
if (data.success == 1) {
console.log('[DoTaskWorkshop] Rate - OK!');
} else {
console.error('[DoTaskWorkshop] Rate - Fail! (4)');
}
}).fail(function() {
console.error('[DoTaskWorkshop] Rate - Fail! (3)');
}).always(function() {
if (!bTaskWorkshopSubscribe || isDone) {
return next();
}
isDone = true;
});
}
if (bTaskWorkshopSubscribe) {
console.log('[DoTaskWorkshop] Subscribing id#' + file_id);
$J.post('//steamcommunity.com/sharedfiles/subscribe', {
id: file_id,
appid: 440,
sessionid: g_sessionID
}).done(function(data) {
if (data.success == 1) {
console.log('[DoTaskWorkshop] Subscribe - OK!');
$J.post('//steamcommunity.com/sharedfiles/unsubscribe', {
id: file_id,
appid: 440,
sessionid: g_sessionID
}).done(function(data) {
if (data.success == 1) {
console.log('[DoTaskWorkshop] Unsubscribed');
}
});
} else {
console.error('[DoTaskWorkshop] Subscribe - Fail! (4)');
}
}).fail(function() {
console.error('[DoTaskWorkshop] Subscribe - Fail! (3)');
}).always(function() {
if (!bTaskWorkshopRate || isDone) {
return next();
}
isDone = true;
});
}
}).fail(function() {
console.error('[DoTaskWorkshop] Fail! (1)');
next();
});
}
function DoTaskCommunityProfile(next) {
$J.get('//steamcommunity.com/' + g_ProfilePath + '/edit').done(function(data) {
var form = $J(data).find('form').eq(0);
if (bTaskCommunityProfileRealName) {
form.find('#real_name').val('Bot' + Math.floor(Math.random() * 1e3));
}
form.find('#summary').val('Hi, I am Bot!');
$J.post('//steamcommunity.com/' + g_ProfilePath + '/edit', form.serialize()).done(function(data) {
console.log('[DoTaskCommunityProfile] OK!');
}).fail(function() {
console.error('[DoTaskCommunityProfile] Fail! (2)');
}).always(function() {
next();
});
}).fail(function() {
console.error('[DoTaskCommunityProfile] Fail! (1)');
next();
});
}
function DoTaskJoinGroup(next) {
$J.post('//steamcommunity.com/groups/tradingcards', {
action: 'join',
sessionID: g_sessionID
}).done(function() {
console.log('[DoTaskJoinGroup] OK!');
}).fail(function() {
console.error('[DoTaskJoinGroup] Fail!');
}).always(function() {
next();
});
}
function DoTaskProfileComment(next) {
$J.post('//steamcommunity.com/comment/Profile/post/' + g_steamID + '/-1/', {
comment: ':steammocking:',
count: 0,
sessionid: g_sessionID
}).done(function(data) {
if (data.success) {
console.log('[DoTaskProfileComment] OK!');
} else {
console.error('[DoTaskProfileComment] Fail! (2)');
}
}).fail(function() {
console.error('[DoTaskProfileComment] Fail! (1)');
}).always(function() {
next();
});
}
function DoTaskFeedRateUp(next) {
$J.post('//steamcommunity.com/actions/LogFriendActivityUpvote', {
sessionID: g_sessionID
}).done(function() {
console.log('[DoTaskFeedRateUp] OK!');
}).fail(function() {
console.error('[DoTaskFeedRateUp] Fail!');
}).always(function() {
next();
});
}
function DoTaskPostStatus(next) {
$J.post('//steamcommunity.com/' + g_ProfilePath + '/ajaxpostuserstatus/', {
sessionid: g_sessionID,
status_text: 'Hello World!',
appid: 0
}).done(function(data) {
if (data.success && data.blotter_html) {
console.log('[DoTaskPostStatus] OK!');
var postid = data.blotter_html.match(/userstatus_(\d+)_/)[1];
$J.post('//steamcommunity.com/' + g_ProfilePath + '/ajaxdeleteuserstatus/', {
sessionid: g_sessionID,
postid: postid
}).done(function(data) {
if (data.success) {
console.log('[DoTaskPostStatus] Post removed');
}
});
} else {
console.error('[DoTaskPostStatus] Fail! (2)');
}
}).fail(function() {
console.error('[DoTaskPostStatus] Fail! (1)');
}).always(function() {
next();
});
}
function DoTaskSelectBadge(next) {
$J.post('', { // current page `<profile>/badges/2`
action: 'setfavoritebadge',
sessionid: g_sessionID,
badgeid: 2 // Community Badge
}).done(function(data) {
if (data.indexOf('class="profile_fatalerror"') != -1) {
console.error('[DoTaskSelectBadge] Fail! (2)');
} else {
console.log('[DoTaskSelectBadge] OK!');
}
}).fail(function() {
console.error('[DoTaskSelectBadge] Fail! (1)');
}).always(function() {
next();
});
}
function DoTaskDiscussionsSearch(next) {
$J.ajax({
// Really where? :(
url: '//steamcommunity.com/discussions/forum/search/?gidforum=882958665520871138&q=%57%68%65%72%65%20%69%73%20%48%61%6C%66%2D%4C%69%66%65%20%33%3F',
type: 'HEAD'
}).done(function() {
console.log('[DoTaskDiscussionsSearch] OK!');
}).fail(function() {
console.error('[DoTaskDiscussionsSearch] Fail!');
}).always(function() {
next();
});
}
function DoNextTask() {
var Task = g_TasksQueue.shift();
if (Task) {
Task(DoNextTask);
} else {
console.log('Done! Refresh the page and see what happened')
}
};
if (bTaskBroadcast) {
g_TasksQueue.push(DoTaskBroadcast);
console.log('Added task `Broadcast`');
}
if (bTaskGameWishlist) {
g_TasksQueue.push(DoTaskGameWishlist);
console.log('Added task `GameWishlist`');
}
if (bTaskWorkshop) {
g_TasksQueue.push(DoTaskWorkshop);
console.log('Added task `Workshop`');
}
if (bTaskCommunityProfile) {
g_TasksQueue.push(DoTaskCommunityProfile);
console.log('Added task `CommunityProfile`');
}
if (bTaskJoinGroup) {
g_TasksQueue.push(DoTaskJoinGroup);
console.log('Added task `JoinGroup`');
}
if (bTaskProfileComment) {
g_TasksQueue.push(DoTaskProfileComment);
console.log('Added task `ProfileComment`');
}
if (bTaskFeedRateUp) {
g_TasksQueue.push(DoTaskFeedRateUp);
console.log('Added task `FeedRateUp`');
}
if (bTaskPostStatus) {
g_TasksQueue.push(DoTaskPostStatus);
console.log('Added task `PostStatus`');
}
if (bTaskDiscussionsSearch) {
g_TasksQueue.push(DoTaskDiscussionsSearch);
console.log('Added task `DiscussionsSearch`');
}
if (bTaskSelectBadge) {
g_TasksQueue.push(DoTaskSelectBadge);
console.log('Added task `SelectBadge`');
}
if (!g_TasksQueue.length) {
console.log('Nothing to do. Great job! :)');
return;
}
DoNextTask();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment