gazellegames GGn New Uploady

Steam Uploady Fork for GGn | Greasemonkey 4.1: ✕ Tampermonkey 4.4: ✔

  1. // ==UserScript==
  2. // @name gazellegames GGn New Uploady
  3. // @namespace https://gazellegames.net/
  4. // @version 6.4
  5. // @description Steam Uploady Fork for GGn | Greasemonkey 4.1: ✕ Tampermonkey 4.4: ✔
  6. // @author NeutronNoir
  7. // @match https://gazellegames.net/upload.php*
  8. // @require https://code.jquery.com/jquery-3.1.1.min.js
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11.  
  12.  
  13. var askScreens = false;
  14.  
  15. function html2bb(str) {
  16. if(typeof str === "undefined") return "";
  17.  
  18. str = str.replace(/\r/g, "");
  19. str = str.replace(/\n/g, "");
  20. str = str.replace(/< *br *\/*>/g, "\n");
  21. str = str.replace(/< *u *>/g, "[u]");
  22. str = str.replace(/< *h1*>/g, "[align=center][u]");
  23. str = str.replace(/< *\/h1*>/g, "[/u]\n\n[/align]");
  24. str = str.replace(/< *\/p*>/g, "");
  25. str = str.replace(/< *p*>/g, "");
  26. str = str.replace(/< *\/ *u *>/g, "[/u]");
  27. str = str.replace(/< *\/ *li *>/g, "");
  28. str = str.replace(/< *li *>/g, "[*]");
  29. str = str.replace(/< *\/ *ul *>/g, "");
  30. str = str.replace(/< *ul *class=\\*\"bb_ul\\*\" *>/g, "");
  31. str = str.replace(/< *h2 *class=\"bb_tag\" *>/g, "\n\n[u]");
  32. str = str.replace(/< *\/ *h2 *>/g, "[/u]\n\n");
  33. str = str.replace(/< *strong *>/g, "[b]");
  34. str = str.replace(/< *\/ *strong *>/g, "[/b]");
  35. str = str.replace(/< *i *>/g, "[i]");
  36. str = str.replace(/< *\/ *i *>/g, "[/i]");
  37. str = str.replace(/\&quot;/g, "\"");
  38. str = str.replace(/< *img *src="([^"]*)" *>/g, "");
  39. str = str.replace(/< *b *>/g, "[b]");
  40. str = str.replace(/< *\/ *b *>/g, "[/b]");
  41. str = str.replace(/< *a [^>]*>/g, "");
  42. str = str.replace(/< *\/ *a *>/g, "");
  43. str = str.replace(/\n\n\n/g, "\n\n");
  44. //Yeah, all these damn stars. Because people put spaces where they shouldn't.
  45. return str;
  46. }
  47.  
  48. function clickAllPtp(){
  49. var list = document.querySelectorAll("input");
  50. for (var i = 0; i < list.length; i++) { if(list[i].value=='PTPImg It'){list[i].click()}}
  51. }
  52.  
  53. (function() {
  54. 'use strict';
  55. if (window.location.href.search("action=editgroup") != -1) {
  56. $("td.center").parent().after("<tr><td class='label'>Steam ID</td><td><input id='steamid' /></td></tr>");
  57. document.getElementById("steamid").addEventListener("blur", function() { //After the "appid" input loses focus
  58. var request = new GM_xmlhttpRequest({method: "GET", //We call the Steam API to get info on the game
  59. url: "http://store.steampowered.com/api/appdetails?l=en&appids=" + document.getElementById("steamid").value,
  60. responseType: "json",
  61. onload: function(response) {
  62.  
  63. var gameInfo = response.response[document.getElementById("steamid").value].data; //We store the data in gameInfo, since it's much easier to access this way
  64.  
  65. var addScreens = true;
  66. if (askScreens === true) addScreens = confirm("Fill the screenshot boxes ?");
  67.  
  68. if (addScreens === true) {
  69. $("input[name='image']").val(gameInfo.header_image.split("?")[0]); //Get the image URL
  70. var screens = document.getElementsByName("screens[]"); //Get each element corresponding to a screenshot
  71. var add_screen = $("#image_block a[href='#']").first(); //This is a shortcut to add a screenshot field.
  72. //If I didn't do this, people with access to "whatimg it" wouldn't have it, or inversely people without access would have it (which causes some bugs)
  73. gameInfo.screenshots.forEach( function(screen, index) { //We iterate on Steam screenshots from the API
  74. if (index >= 16) return; //The site doesn't accept more than 16 screenshots
  75. if (index >= 3) add_screen.click(); //There's 3 screenshot boxes by default. If we need to add more, we do as if the user clicked on the "[+]" (for reasons mentioned above)
  76. screens[index].value = screen.path_full.split("?")[0]; //Finally store the screenshot link in the right screen field.
  77. });
  78. }
  79. }
  80. });
  81. });
  82. }
  83. else {
  84. document.getElementById("steamid").addEventListener("blur", function() { //After the "appid" input loses focus
  85. var request = new GM_xmlhttpRequest({method: "GET", //We call the Steam API to get info on the game
  86. url: "http://store.steampowered.com/api/appdetails?l=en&appids=" + document.getElementById("steamid").value,
  87. responseType: "json",
  88. onload: function(response) {
  89.  
  90. var gameInfo = response.response[document.getElementById("steamid").value].data; //We store the data in gameInfo, since it's much easier to access this way
  91. document.getElementById("title").value = gameInfo.name; //Get the name of the game
  92. document.getElementById("album_desc").value = "[align=center][b][u]About the game[/u][/b][/align]\n" + html2bb(gameInfo.about_the_game); //Get the description, formatted appropriately
  93. document.getElementById("year").value = gameInfo.release_date.date.split(", ").pop(); //Get the year, which is actually the last number of "release_date.date"
  94.  
  95. //Genres are in an object array. Need to make them lowercase, replace spaces with dots and separate them with ", "
  96. var genres = [];
  97. gameInfo.genres.forEach(function (genre) {
  98. var tag = genre.description.toLowerCase().replace(/ /g, "."); //Each genre is formatted as mentioned above and added to the "genres" array
  99. switch (tag) {
  100. case "rpg":
  101. genres.push("role.playing.game");
  102. break;
  103. case "early.access":
  104. break;
  105. case "sexual.content":
  106. genres.push("adult");
  107. break;
  108. case "scifi":
  109. genres.push("science.fiction");
  110. break;
  111. default:
  112. genres.push(tag);
  113. break;
  114. }
  115.  
  116. });
  117. document.getElementById("tags").value = genres.join(", "); //Every string in the "genres" array is then concatenated with ", " between them
  118.  
  119. var addScreens = true;
  120. if (askScreens === true) addScreens = confirm("Fill the screenshot boxes ?");
  121.  
  122. if (addScreens === true) {
  123. document.getElementById("image").value = gameInfo.header_image.split("?")[0]; //Get the image URL
  124. var screens = document.getElementsByName("screens[]"); //Get each element corresponding to a screenshot
  125. var add_screen = $("#image_block a[href='#']").first(); //This is a shortcut to add a screenshot field.
  126. //If I didn't do this, people with access to "whatimg it" wouldn't have it, or inversely people without access would have it (which causes some bugs)
  127. gameInfo.screenshots.forEach( function(screen, index) { //We iterate on Steam screenshots from the API
  128. if (index >= 16) return; //The site doesn't accept more than 16 screenshots
  129. if (index >= 3) add_screen.click(); //There's 3 screenshot boxes by default. If we need to add more, we do as if the user clicked on the "[+]" (for reasons mentioned above)
  130. screens[index].value = screen.path_full.split("?")[0]; //Finally store the screenshot link in the right screen field.
  131. });
  132. }
  133.  
  134.  
  135. //Now let's get the requirements
  136. document.getElementById("album_desc").value += "\n\n[quote][align=center][b][u]System Requirements[/u][/b][/align]\n"; //The requirements need to be in the description of the torrent.
  137. switch (document.getElementById("platform").value) {
  138. case "Windows":
  139. document.getElementById("album_desc").value += html2bb(gameInfo.pc_requirements.minimum) + "\n\n" + html2bb(gameInfo.pc_requirements.recommended); //We add the requirements, both minimal and recommended, formatted appropriately.
  140. break;
  141. case "Linux":
  142. document.getElementById("album_desc").value += html2bb(gameInfo.linux_requirements.minimum) + "\n\n" + html2bb(gameInfo.linux_requirements.recommended);
  143. break;
  144. case "Mac":
  145. document.getElementById("album_desc").value += html2bb(gameInfo.mac_requirements.minimum) + "\n\n" + html2bb(gameInfo.mac_requirements.recommended);
  146. break;
  147. }
  148.  
  149. document.getElementById("album_desc").value += "[/quote]";
  150. }
  151. });
  152. });
  153. }
  154. })();