Greasy Fork镜像 支持简体中文。

Gaddons Download Button Atualizado

Coloca um botão de dowload na workshop do Garry´s Mod

  1. // ==UserScript==
  2. // @name Gaddons Download Button Atualizado
  3. // @namespace http://userscripts.org/users/457713
  4. // @description Coloca um botão de dowload na workshop do Garry´s Mod
  5. // @include *http://gaddonsv3.tk/*
  6. // @include *steamcommunity.com/sharedfiles/filedetails/?id=*
  7. // @version 1.3
  8. // ==/UserScript==
  9.  
  10. var patt=new RegExp("[0-9]{2,15}");
  11. var id = patt.exec(document.URL);
  12.  
  13. var baseURL = "http://gaddonsv3.tk/";
  14.  
  15. if (document.URL.indexOf("garrysmod.org") != -1)
  16. {
  17. addGMODBtn();
  18. }
  19. else if (document.URL.indexOf("steamcommunity.com") != -1)
  20. {
  21. addWorkshopBtn(id);
  22. }
  23.  
  24. function addWorkshopBtn(id)
  25. {
  26. var element = document.getElementById("SubscribeItemBtn");
  27.  
  28. var button = document.createElement('a');
  29. button.setAttribute('class', 'btn_green_white_innerfade btn_border_2px btn_medium');
  30. button.setAttribute('href', baseURL + 'workshop/' + id + '/');
  31. button.setAttribute('style', 'right: 160px;');
  32.  
  33. button.innerHTML = '<div class="subscribeIcon"></div>' +
  34. '<span class="subscribeText">' +
  35. '<div class="subscribeOption subscribe selected" id="SubscribeItemOptionAdd">Download</div>' +
  36. '</span>';
  37.  
  38. // Append the element after the real subscribe button
  39. if (element.nextSibling)
  40. {
  41. element.parentNode.insertBefore(button, element.nextSibling);
  42. }
  43. else
  44. {
  45. element.parentNode.appendChild(button);
  46. }
  47.  
  48. // Change the stupid text to the left of it
  49. document.querySelectorAll(".game_area_purchase_game")[0].getElementsByTagName('h1')[0].innerHTML = "Visit Gaddons.org for GMOD 12 addons"
  50. }
  51.  
  52. function addGMODBtn()
  53. {
  54. var element = document.getElementsByTagName("form")[1];
  55.  
  56. var button = document.createElement('input');
  57. button.setAttribute('type', 'button');
  58. button.setAttribute('id', 'gaddonsBtn');
  59. button.setAttribute('style', 'width: 200px; font-size: 15px; margin-top: 15px;');
  60. button.setAttribute('value', 'Download @ Gaddons.org');
  61. button.addEventListener('click', visitGaddons, false);
  62. element.appendChild(button);
  63. }
  64.  
  65. function visitGaddons()
  66. {
  67. var mirrorsLink = baseURL + "addons/" + id + "/";
  68. var addonName = document.getElementById("downloadtitle").getElementsByTagName("h2").item(0).innerHTML;
  69.  
  70. post_to_url(mirrorsLink, {'name' : addonName});
  71. }
  72.  
  73. function post_to_url(path, params)
  74. {
  75. var form = document.createElement("form");
  76. form.setAttribute("method", "post");
  77. form.setAttribute("action", path);
  78.  
  79. for(var key in params)
  80. {
  81. if(params.hasOwnProperty(key))
  82. {
  83. var hiddenField = document.createElement("input");
  84. hiddenField.setAttribute("type", "hidden");
  85. hiddenField.setAttribute("name", key);
  86. hiddenField.setAttribute("value", params[key]);
  87.  
  88. form.appendChild(hiddenField);
  89. }
  90. }
  91.  
  92. document.body.appendChild(form);
  93. form.submit();
  94. }

QingJ © 2025

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