Guest User

Steam

a guest
Sep 9th, 2017
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. 'use strict';
  2. (function() {
  3. if (!location.href.match(/^https?:\/\/steamcommunity.com\/(?:id|profiles)\/[^\/]+\/badges\/2/)) {
  4. location.href = '//steamcommunity.com/my/badges/2';
  5. return;
  6. }
  7. if (!g_steamID) {
  8. alert('No logged on!');
  9. return;
  10. }
  11. var k_ExpectedTasksCount = 29;
  12. var g_SteamTasks = $J('.badge_task');
  13. if (g_SteamTasks.length != k_ExpectedTasksCount) {
  14. console.error('Expected tasks ' + k_ExpectedTasksCount + ', but found ' + g_SteamTasks.length);
  15. console.error('Stopped');
  16. return;
  17. }
  18. var g_TasksQueue = [];
  19. var bTaskBroadcast = isTaskAvailable(3);
  20. var bTaskWorkshopRate = isTaskAvailable(11);
  21. var bTaskWorkshopSubscribe = isTaskAvailable(12);
  22. var bTaskWorkshop = bTaskWorkshopRate || bTaskWorkshopSubscribe;
  23. var bTaskGreenlightVote = isTaskAvailable(14);
  24. var bTaskCommunityProfileRealName = isTaskAvailable(16);
  25. var bTaskCommunityProfile = bTaskCommunityProfileRealName || isTaskAvailable(15) || isTaskAvailable(17);
  26. var bTaskJoinGroup = isTaskAvailable(18);
  27. var bTaskProfileComment = isTaskAvailable(19);
  28. var bTaskFeedRateUp = isTaskAvailable(20);
  29. var bTaskPostStatus = isTaskAvailable(21);
  30. var bTaskSelectBadge = isTaskAvailable(24);
  31. var bTaskDiscussionsSearch = isTaskAvailable(26);
  32. function isTaskAvailable(task_id) {
  33. var task = g_SteamTasks.eq(task_id);
  34. if (!task.length)
  35. return false;
  36. return task.find('.quest_icon').attr('src').indexOf('_off') != -1;
  37. }
  38. function DoTaskBroadcast(next) {
  39. $J.get('//steamcommunity.com/apps/allcontenthome?appHubSubSection=13').done(function(data) {
  40. // first available broadcast
  41. var match = data.match(/watch\/(\d+)/);
  42. if (!match) {
  43. console.error('[DoTaskBroadcast] Fail! (2)');
  44. return next();
  45. }
  46. $J.get('//steamcommunity.com/broadcast/getbroadcastmpd/?steamid=' + match[1] + '&broadcastid=0&viewertoken=0').done(function(data) {
  47. if (data.success !== 'ready') {
  48. console.error('[DoTaskBroadcast] Fail! (4)');
  49. } else {
  50. console.log('[DoTaskBroadcast] OK!');
  51. }
  52. }).fail(function() {
  53. console.error('[DoTaskBroadcast] Fail! (3)');
  54. }).always(function() {
  55. next();
  56. });
  57. }).fail(function() {
  58. console.error('[DoTaskBroadcast] Fail! (1)');
  59. next();
  60. });
  61. }
  62. function DoTaskWorkshop(next) {
  63. $J.get('//steamcommunity.com/workshop/browse/', {
  64. appid: 440,
  65. browsesort: 'totaluniquesubscribers'
  66. }).done(function(data) {
  67. var matches = data.match(/sharedfile_(\d+)/g);
  68. if (!matches) {
  69. console.error('[DoTaskWorkshop] Fail! (2)');
  70. return next();
  71. }
  72. var file_id = matches[Math.floor(Math.random() * matches.length)].substr(11);
  73. var isDone = false;
  74. if (bTaskWorkshopRate) {
  75. console.log('[DoTaskWorkshop] Upvoting id#' + file_id);
  76. $J.post('//steamcommunity.com/sharedfiles/voteup', {
  77. id: file_id,
  78. sessionid: g_sessionID
  79. }).done(function(data) {
  80. if (data.success == 1) {
  81. console.log('[DoTaskWorkshop] Rate - OK!');
  82. } else {
  83. console.error('[DoTaskWorkshop] Rate - Fail! (4)');
  84. }
  85. }).fail(function() {
  86. console.error('[DoTaskWorkshop] Rate - Fail! (3)');
  87. }).always(function() {
  88. if (!bTaskWorkshopSubscribe || isDone) {
  89. return next();
  90. }
  91. isDone = true;
  92. });
  93. }
  94. if (bTaskWorkshopSubscribe) {
  95. console.log('[DoTaskWorkshop] Subscribing id#' + file_id);
  96. $J.post('//steamcommunity.com/sharedfiles/subscribe', {
  97. id: file_id,
  98. appid: 440,
  99. sessionid: g_sessionID
  100. }).done(function(data) {
  101. if (data.success == 1) {
  102. console.log('[DoTaskWorkshop] Subscribe - OK!');
  103. $J.post('//steamcommunity.com/sharedfiles/unsubscribe', {
  104. id: file_id,
  105. appid: 440,
  106. sessionid: g_sessionID
  107. }).done(function(data) {
  108. if (data.success == 1) {
  109. console.log('[DoTaskWorkshop] Unsubscribed');
  110. }
  111. });
  112. } else {
  113. console.error('[DoTaskWorkshop] Subscribe - Fail! (4)');
  114. }
  115. }).fail(function() {
  116. console.error('[DoTaskWorkshop] Subscribe - Fail! (3)');
  117. }).always(function() {
  118. if (!bTaskWorkshopRate || isDone) {
  119. return next();
  120. }
  121. isDone = true;
  122. });
  123. }
  124. }).fail(function() {
  125. console.error('[DoTaskWorkshop] Fail! (1)');
  126. next();
  127. });
  128. }
  129. function DoTaskGreenlightVote(next) {
  130. $J.get('//steamcommunity.com/workshop/browse/', {
  131. appid: 765,
  132. browsesort: 'mostrecent',
  133. 'requiredtags[]': 'Simulation'
  134. }).done(function(data) {
  135. var matches = data.match(/sharedfile_(\d+)/g);
  136. if (!matches) {
  137. console.error('[DoTaskGreenlightVote] Fail! (2)');
  138. return next();
  139. }
  140. var file_id = matches[Math.floor(Math.random() * matches.length)].substr(11);
  141. // D'OH! I hate simulators (⇀‸↼•)
  142. console.log('[DoTaskGreenlightVote] Downvoting id#' + file_id);
  143. $J.post('//steamcommunity.com/sharedfiles/votedown', {
  144. id: file_id,
  145. sessionid: g_sessionID
  146. }).done(function(data) {
  147. if (data.success == 1) {
  148. console.log('[DoTaskGreenlightVote] OK!');
  149. } else {
  150. console.error('[DoTaskGreenlightVote] Fail! (4)');
  151. }
  152. }).fail(function() {
  153. console.error('[DoTaskGreenlightVote] Fail! (3)');
  154. }).always(function() {
  155. next();
  156. });
  157. }).fail(function() {
  158. console.error('[DoTaskGreenlightVote] Fail! (1)');
  159. next();
  160. });
  161. }
  162. function DoTaskCommunityProfile(next) {
  163. $J.get('//steamcommunity.com/profiles/' + g_steamID + '/edit').done(function(data) {
  164. var form = $J(data).find('form').eq(0);
  165. if (bTaskCommunityProfileRealName) {
  166. form.find('#real_name').val(form.find('#personaName').val())
  167. }
  168. $J.post('//steamcommunity.com/profiles/' + g_steamID + '/edit', form.serialize()).done(function(data) {
  169. console.log('[DoTaskCommunityProfile] OK!');
  170. }).fail(function() {
  171. console.error('[DoTaskCommunityProfile] Fail! (2)');
  172. }).always(function() {
  173. next();
  174. });
  175. }).fail(function() {
  176. console.error('[DoTaskCommunityProfile] Fail! (1)');
  177. next();
  178. });
  179. }
  180. function DoTaskJoinGroup(next) {
  181. $J.post('//steamcommunity.com/groups/tradingcards', {
  182. action: 'join',
  183. sessionID: g_sessionID
  184. }).done(function() {
  185. console.log('[DoTaskJoinGroup] OK!');
  186. }).fail(function() {
  187. console.error('[DoTaskJoinGroup] Fail!');
  188. }).always(function() {
  189. next();
  190. });
  191. }
  192. function DoTaskProfileComment(next) {
  193. $J.post('//steamcommunity.com/comment/Profile/post/' + g_steamID + '/-1/', {
  194. comment: ':steammocking:',
  195. count: 0,
  196. sessionid: g_sessionID
  197. }).done(function(data) {
  198. if (data.success) {
  199. console.log('[DoTaskProfileComment] OK!');
  200. } else {
  201. console.error('[DoTaskProfileComment] Fail! (2)');
  202. }
  203. }).fail(function() {
  204. console.error('[DoTaskProfileComment] Fail! (1)');
  205. }).always(function() {
  206. next();
  207. });
  208. }
  209. function DoTaskFeedRateUp(next) {
  210. $J.post('//steamcommunity.com/actions/LogFriendActivityUpvote', {
  211. sessionID: g_sessionID
  212. }).done(function() {
  213. console.log('[DoTaskFeedRateUp] OK!');
  214. }).fail(function() {
  215. console.error('[DoTaskFeedRateUp] Fail!');
  216. }).always(function() {
  217. next();
  218. });
  219. }
  220. function DoTaskPostStatus(next) {
  221. $J.post('//steamcommunity.com/profiles/' + g_steamID + '/ajaxpostuserstatus/', {
  222. sessionid: g_sessionID,
  223. status_text: 'Hello World!',
  224. appid: 0
  225. }).done(function(data) {
  226. if (data.success && data.blotter_html) {
  227. console.log('[DoTaskPostStatus] OK!');
  228. var postid = data.blotter_html.match(/userstatus_(\d+)_/)[1];
  229. $J.post('//steamcommunity.com/profiles/' + g_steamID + '/ajaxdeleteuserstatus/', {
  230. sessionid: g_sessionID,
  231. postid: postid
  232. }).done(function(data) {
  233. if (data.success) {
  234. console.log('[DoTaskPostStatus] Post removed');
  235. }
  236. });
  237. } else {
  238. console.error('[DoTaskPostStatus] Fail! (2)');
  239. }
  240. }).fail(function() {
  241. console.error('[DoTaskPostStatus] Fail! (1)');
  242. }).always(function() {
  243. next();
  244. });
  245. }
  246. function DoTaskSelectBadge(next) {
  247. $J.post('//steamcommunity.com/profiles/' + g_steamID + '/badges/2', {
  248. action: 'setfavoritebadge',
  249. sessionid: g_sessionID,
  250. badgeid: 2 // Community Badge
  251. }).done(function(data) {
  252. if (data.indexOf('class="profile_fatalerror"') != -1) {
  253. console.error('[DoTaskSelectBadge] Fail! (2)');
  254. } else {
  255. console.log('[DoTaskSelectBadge] OK!');
  256. }
  257. }).fail(function() {
  258. console.error('[DoTaskSelectBadge] Fail! (1)');
  259. }).always(function() {
  260. next();
  261. });
  262. }
  263. function DoTaskDiscussionsSearch(next) {
  264. $J.ajax({
  265. // Really where? :(
  266. 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',
  267. type: 'HEAD'
  268. }).done(function() {
  269. console.log('[DoTaskDiscussionsSearch] OK!');
  270. }).fail(function() {
  271. console.error('[DoTaskDiscussionsSearch] Fail!');
  272. }).always(function() {
  273. next();
  274. });
  275. }
  276. function DoNextTask() {
  277. var Task = g_TasksQueue.shift();
  278. if (Task) {
  279. Task(DoNextTask);
  280. } else {
  281. console.log('Done! Refresh the page and see what happened')
  282. }
  283. };
  284. if (bTaskBroadcast) {
  285. g_TasksQueue.push(DoTaskBroadcast);
  286. console.log('Added task `Broadcast`');
  287. }
  288. if (bTaskWorkshop) {
  289. g_TasksQueue.push(DoTaskWorkshop);
  290. console.log('Added task `Workshop`');
  291. }
  292. if (bTaskGreenlightVote) {
  293. g_TasksQueue.push(DoTaskGreenlightVote);
  294. console.log('Added task `GreenlightVote`');
  295. }
  296. if (bTaskCommunityProfile) {
  297. g_TasksQueue.push(DoTaskCommunityProfile);
  298. console.log('Added task `CommunityProfile`');
  299. }
  300. if (bTaskJoinGroup) {
  301. g_TasksQueue.push(DoTaskJoinGroup);
  302. console.log('Added task `JoinGroup`');
  303. }
  304. if (bTaskProfileComment) {
  305. g_TasksQueue.push(DoTaskProfileComment);
  306. console.log('Added task `ProfileComment`');
  307. }
  308. if (bTaskFeedRateUp) {
  309. g_TasksQueue.push(DoTaskFeedRateUp);
  310. console.log('Added task `FeedRateUp`');
  311. }
  312. if (bTaskPostStatus) {
  313. g_TasksQueue.push(DoTaskPostStatus);
  314. console.log('Added task `PostStatus`');
  315. }
  316. if (bTaskDiscussionsSearch) {
  317. g_TasksQueue.push(DoTaskDiscussionsSearch);
  318. console.log('Added task `DiscussionsSearch`');
  319. }
  320. if (bTaskSelectBadge) {
  321. g_TasksQueue.push(DoTaskSelectBadge);
  322. console.log('Added task `SelectBadge`');
  323. }
  324. if (!g_TasksQueue.length) {
  325. console.log('Nothing to do. Great job! :)');
  326. return;
  327. }
  328. DoNextTask();
  329. })();
Add Comment
Please, Sign In to add comment