Steam Community - All Workshop Items Subscriber

Subscribes or unsubscribes to all workshop items from a particular AppID

  1. // ==UserScript==
  2. // @name Steam Community - All Workshop Items Subscriber
  3. // @namespace Royalgamer06
  4. // @version 0.4.1
  5. // @description Subscribes or unsubscribes to all workshop items from a particular AppID
  6. // @author Royalgamer06
  7. // @include *://steamcommunity.com/workshop/browse/?appid=*
  8. // @grant none
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. this.$ = this.$ = $.noConflict(true);
  13. $(document).ready(function() {
  14. var html = '<div class="rightSectionTopTitle">Subscriptions:</div> <div class="rightDetailsBlock"> <div style="position:relative;"> <img class="browseOptionImage" src="http://steamcommunity-a.akamaihd.net/public/images/sharedfiles/filterselect_blue.png?v=1"> <div class="browseOption mostrecent"><a id="suball">Subscribe All</a></div> </div> <div style="position:relative;"> <img class="browseOptionImage" src="http://steamcommunity-a.akamaihd.net/public/images/sharedfiles/filterselect_blue.png?v=1"> <div class="browseOption mostrecent"><a id="unsuball">Unsubscribe All</a></div> </div><hr> </div> </div>';
  15. $(".panel:first").prepend(html);
  16. $("#suball").click(function() { subAll("subscribe"); });
  17. $("#unsuball").click(function() { subAll("unsubscribe"); });
  18. });
  19.  
  20. function subAll(method) {
  21. var modal = ShowBlockingWaitDialog("Executing…", "Please wait until all requests finish. \nThe page will automatically reload when it is finished.");
  22. const appid = location.href.split("appid=")[1].split("&")[0];
  23. var pageinfo = $(".workshopBrowsePagingInfo").text().replace(",", "");
  24. var split = pageinfo.split(" ");
  25. var total = 0;
  26. for (var i = 0; i < split.length; i++) {
  27. if (split[i].match(/^[0-9]+$/) !== null) {
  28. total = parseInt(split[i]);
  29. }
  30. }
  31. var loaded = 1;
  32. const lastpage = Math.ceil(total/30);
  33. for (var p = 1; p <= lastpage; p++) {
  34. var url = location.href;
  35. if (url.indexOf("p=") > -1) {
  36. url = url.split("p=")[0] + "p=" + p + url.split("p=")[1].replace(url.split("p=")[1].split("&")[0], "");
  37. } else {
  38. url = url + "&p=" + p;
  39. }
  40. setTimeout(function() {
  41. $.get(url, function(data) {
  42. data = data.replace(/src="[^"]*"/ig, "");
  43. $(".workshopItemPreviewHolder", data).each(function() {
  44. let wsid = $(this).attr("id").replace("sharedfile_","");
  45. setTimeout(function() {
  46. $.post("//steamcommunity.com/sharedfiles/" + method, { id: wsid, appid: appid, sessionid: g_sessionID }).always(function() {
  47. loaded++;
  48. modal.Dismiss();
  49. if( loaded >= total ) {
  50. location.reload();
  51. } else {
  52. modal = ShowBlockingWaitDialog( 'Executing…', 'Loaded <b>' + loaded + '</b>/' + total + '.' );
  53. }
  54. });
  55. }, 0);
  56. });
  57. delete data;
  58. });
  59. }, 0);
  60. }
  61. }