Enhanced Steam Workshop Downloader

Adds an extra button to download, supports collections and new workshop layout

  1. // ==UserScript==
  2. // @author Sycam Inc (origionally Alvaro)
  3. // @name Enhanced Steam Workshop Downloader
  4. // @description Adds an extra button to download, supports collections and new workshop layout
  5. // @include *steamcommunity.com/sharedfiles/filedetails/?id=*
  6. // @include *steamcommunity.com/workshop/filedetails/?id=*
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  8. // @grant GM_xmlhttpRequest
  9. // @version 2.1
  10. // @license MIT
  11. // @namespace https://gf.qytechs.cn/users/6073
  12. // ==/UserScript==
  13.  
  14.  
  15. var patt = new RegExp("[0-9]{2,15}");
  16. var id = patt.exec(document.URL);
  17. var baseURL = "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v0001/";
  18. var baseURLCtn = "http://api.steampowered.com/ISteamRemoteStorage/GetCollectionDetails/v0001/";
  19.  
  20.  
  21. if (document.URL.indexOf("steamcommunity.com") != -1) {
  22. if (document.URL.indexOf("workshop") != -1) {
  23. addCollectionBtn(id);
  24. } else {
  25. addWorkshopBtn(id);
  26. }
  27. }
  28.  
  29. function prepareDownload(url, id) {
  30. GM_xmlhttpRequest({
  31. method: "POST",
  32. url: url,
  33. data: "itemcount=1&publishedfileids[0]=" + id + "&format=json",
  34. headers: {
  35. "Content-Type": "application/x-www-form-urlencoded"
  36. },
  37. onload: function (response) {
  38. //console.log(response.responseText);
  39. //debugger;
  40. data = jQuery.parseJSON(response.responseText);
  41. var fileurl = data.response.publishedfiledetails[0].file_url;
  42. $("#SubscribeItemOptionAdd2").click(function (e) {
  43. e.preventDefault(); //stop the browser from following
  44. window.location.href = fileurl;
  45. });
  46. },
  47. onerror: function (reponse) {
  48. //alert('error');
  49. console.log(reponse);
  50. }
  51. });
  52. }
  53.  
  54. function download(url, id) {
  55. GM_xmlhttpRequest({
  56. method: "POST",
  57. url: url,
  58. data: "itemcount=1&publishedfileids[0]=" + id + "&format=json",
  59. headers: {
  60. "Content-Type": "application/x-www-form-urlencoded"
  61. },
  62. onload: function (response) {
  63. //console.log(response.responseText);
  64. //debugger;
  65. data = jQuery.parseJSON(response.responseText);
  66. var fileurl = data.response.publishedfiledetails[0].file_url;
  67. console.log(fileurl);
  68. window.open(fileurl);
  69. },
  70. onerror: function (reponse) {
  71. //alert('error');
  72. console.log(reponse);
  73. }
  74. });
  75. }
  76.  
  77. function addWorkshopBtn(id) {
  78. var element = document.getElementById("AddToCollectionBtn");
  79. var button = document.createElement('span');
  80. button.setAttribute('class', 'general_btn share tooltip');
  81. //button.setAttribute('href', baseURLCtn + id);
  82.  
  83.  
  84. button.innerHTML = '<span id="SubscribeItemOptionAdd2"><span>Скачать дополнение</span></span>';
  85. // Append the element after the real subscribe button
  86. if (element.nextSibling) {
  87. element.parentNode.insertBefore(button, element.nextSibling);
  88. } else {
  89. element.parentNode.appendChild(button);
  90. }
  91. prepareDownload(baseURL, id);
  92. // Change the stupid text to the left of it
  93. document.querySelectorAll(".game_area_purchase_game")[0].getElementsByTagName('h1')[0].setAttribute('style', 'width: 300px;');
  94. }
  95.  
  96.  
  97. function addCollectionBtn(id) {
  98. var element = document.getElementById("AddToCollectionBtn");
  99.  
  100.  
  101. var button = document.createElement('span');
  102. button.setAttribute('class', 'general_btn share tooltip');
  103. //button.setAttribute('href', baseURLCtn + id);
  104.  
  105.  
  106. button.innerHTML = '<span id="SubscribeItemOptionAdd2"><span>Download</span></span>';
  107.  
  108.  
  109. // Append the element after the real subscribe button
  110. if (element.nextSibling) {
  111. element.parentNode.insertBefore(button, element.nextSibling);
  112. } else {
  113. element.parentNode.appendChild(button);
  114. }
  115. prepareDownloadCtn(baseURLCtn, id);
  116. // Change the stupid text to the left of it
  117. document.querySelectorAll(".game_area_purchase_game")[0].getElementsByTagName('h1')[0].setAttribute('style', 'width: 300px;');
  118. }
  119.  
  120.  
  121. function prepareDownloadCtn(url, id) {
  122. GM_xmlhttpRequest({
  123. method: "POST",
  124. url: url,
  125. data: "collectioncount=1&publishedfileids[0]=" + id + "&format=json",
  126. headers: {
  127. "Content-Type": "application/x-www-form-urlencoded"
  128. },
  129. onload: function (response) {
  130. //console.log(response);
  131. data = jQuery.parseJSON(response.responseText);
  132. $("#SubscribeItemOptionAdd2").click(function (e) {
  133. e.preventDefault(); //stop the browser from following
  134. $.each(data.response.collectiondetails[0].children, function(index, element) {
  135. download(baseURL,element.publishedfileid);
  136. });
  137. });
  138. },
  139. onerror: function (reponse) {
  140. //alert('error');
  141. console.log(reponse);
  142. }
  143. });
  144. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址