Greasy Fork镜像 支持简体中文。

GiveAwaySuHelper

try to take over the world!

  1. // ==UserScript==
  2. // @name GiveAwaySuHelper
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author sollyu
  7. // @icon https://giveaway.su/favicon-96x96.png
  8. // @match *://*.giveaway.su/giveaway/view/*
  9. // @connect steamcommunity.com
  10. // @connect steampowered.com
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_deleteValue
  14. // @grant GM_addStyle
  15. // @grant GM_xmlhttpRequest
  16. // @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
  17. // @run-at document-end
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. var steamHeper = new SteamHelper();
  22.  
  23. function onButtonClickJoin() {
  24. var button = $(this).text('...')
  25.  
  26. GM_xmlhttpRequest({
  27. url: "https://giveaway.su/action/redirect/" + $(this).attr("data-action-id"),
  28. method: 'GET',
  29. onload: function(response) {
  30. if (response.finalUrl.startsWith('https://store.steampowered.com/curator/')) {
  31. var clanID = response.finalUrl.match(/([0-9]+)/);
  32. clanID = clanID === null ? null : clanID[1];
  33. steamHeper.followCurator(clanID, function(){ button.text('完') })
  34. }
  35.  
  36. else if (response.finalUrl.startsWith('https://steamcommunity.com/groups/')) {
  37. steamHeper.joinSteamGroup(response.finalUrl, function(){ button.text('完') })
  38. }
  39.  
  40. else if (response.finalUrl.startsWith('https://store.steampowered.com/app/')) {
  41. var appID = response.finalUrl.match(/([0-9]+)/);
  42. appID = appID === null ? null : appID[1];
  43. steamHeper.addToWishList(appID, function(){ steamHeper.followGame(appID, function() { button.text('完') }) })
  44. }
  45. }
  46. })
  47. }
  48.  
  49. function onButtonClickLeave() {
  50. var button = $(this).text('...')
  51. var finishNumber = 0
  52. var actionSize = GM_getValue(window.location.pathname).length
  53. $.each(GM_getValue(window.location.pathname), function(index, value) {
  54. GM_xmlhttpRequest({
  55. url : "https://giveaway.su/action/redirect/"+value,
  56. method: 'GET',
  57. onload: function(response) {
  58. finishNumber = finishNumber + 1
  59. console.log(finishNumber)
  60. if (finishNumber == actionSize) { button.text('全部已经完成') }
  61.  
  62. if (response.finalUrl.startsWith('https://store.steampowered.com/curator/')) {
  63. var clanID = response.finalUrl.match(/([0-9]+)/);
  64. clanID = clanID === null ? null : clanID[1];
  65. steamHeper.unfollowCurator(clanID, function(){})
  66. }else if (response.finalUrl.startsWith('https://steamcommunity.com/groups/')) {
  67. steamHeper.getGroupID(response.finalUrl, function(groupID) { steamHeper.leaveSteamGroup(groupID, function(){}) })
  68. }else if (response.finalUrl.startsWith('https://store.steampowered.com/app/')) {
  69. var appID = response.finalUrl.match(/([0-9]+)/);
  70. appID = appID === null ? null : appID[1];
  71. steamHeper.removeToWishList(appID, function(){ steamHeper.unfollowGame(appID, function() { }) })
  72. }
  73. },
  74. onerror: function(response) {
  75. finishNumber = finishNumber + 1
  76. console.log(finishNumber)
  77. if (finishNumber == actionSize) { button.text('全部已经完成') }
  78. }
  79. })
  80. })
  81. }
  82.  
  83. function SteamHelper() {
  84. this.groupSessionID = null;
  85. this.curatorSessionID = null;
  86. this.wishlistID = null;
  87. this.userId = null;
  88. this.processUrl = null;
  89.  
  90. this.init = function(callback) {
  91. var that = this;
  92. GM_xmlhttpRequest({
  93. url : "https://steamcommunity.com/my/groups",
  94. method: "GET",
  95. onload: function(response) {
  96. // debugger;
  97. that.userId = response.responseText.match(/g_steamID = \"(.+?)\";/);
  98. that.groupSessionID = response.responseText.match(/g_sessionID = \"(.+?)\";/);
  99. that.processUrl = response.responseText.match(/steamcommunity.com\/(id\/.+?|profiles\/[0-9]+)\/friends\//);
  100. that.userId = that.userId === null ? null : that.userId[1];
  101. that.groupSessionID = that.groupSessionID === null ? null : that.groupSessionID[1];
  102. that.processUrl = that.processUrl === null ? null : "https://steamcommunity.com/" + that.processUrl[1] + "/home_process";
  103.  
  104. GM_xmlhttpRequest({
  105. url : 'https://store.steampowered.com/wishlist/profiles/',
  106. method: 'GET',
  107. onload: function(response) {
  108. that.curatorSessionID = response.responseText.match(/g_sessionID = \"(.+?)\";/);
  109. that.wishlistID = response.finalUrl.match(/([0-9]+)/);
  110.  
  111. that.curatorSessionID = that.curatorSessionID === null ? null : that.curatorSessionID[1];
  112. that.wishlistID = that.wishlistID === null ? null : that.wishlistID[1];
  113.  
  114. if($(".giveaway-info-block").find(".text-right").length == 0) {
  115. callback(false)
  116. }else {
  117. var actionID=[]
  118. $(".giveaway-info-block").find(".text-right").each(function(index, value){
  119. $(this).append( $('<button type="button" class="btn btn-xs btn-default" data-action-id="' +$(this).parent().attr('data-action-id')+ '">加</button>').click(onButtonClickJoin))
  120. actionID.push($(this).parent().attr('data-action-id'))
  121. });
  122. GM_setValue(window.location.pathname, actionID)
  123. callback(true)
  124. }
  125. }
  126. });
  127. }
  128. });
  129. }
  130.  
  131. this.joinSteamGroup = function(groupUrl, callback) {
  132. var that = this;
  133. GM_xmlhttpRequest({
  134. url : groupUrl,
  135. method : 'POST',
  136. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  137. data : $.param({ action: 'join', sessionID: that.groupSessionID }),
  138. onload : function(response) {
  139. callback()
  140. }
  141. });
  142. }
  143.  
  144. this.leaveSteamGroup = function(groupId, callback) {
  145. var that = this;
  146. GM_xmlhttpRequest({
  147. url : that.processUrl,
  148. method : 'POST',
  149. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  150. data : $.param({ sessionID: that.groupSessionID, action: "leaveGroup", groupId: groupId }),
  151. onload : function(response) {
  152. callback()
  153. }
  154. });
  155. }
  156.  
  157. this.followCurator = function(clanID, callback) {
  158. var that = this;
  159. GM_xmlhttpRequest({
  160. url : 'https://store.steampowered.com/curators/ajaxfollow',
  161. method : 'POST',
  162. headers : {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  163. data : $.param({ clanid: clanID, follow: '1', sessionid: that.curatorSessionID }),
  164. onload : function(response) {
  165. callback()
  166. }
  167. });
  168. }
  169.  
  170. this.unfollowCurator = function(clanID, callback) {
  171. var that = this;
  172. GM_xmlhttpRequest({
  173. url : 'https://store.steampowered.com/curators/ajaxfollow',
  174. method : 'POST',
  175. headers : {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  176. data : $.param({ clanid: clanID, follow: '0', sessionid: that.curatorSessionID }),
  177. onload : function(response) {
  178. callback()
  179. }
  180. });
  181. }
  182.  
  183. this.followGame = function(appID, callback) {
  184. var that = this;
  185. GM_xmlhttpRequest({
  186. url : 'https://store.steampowered.com/explore/followgame/',
  187. method : 'POST',
  188. headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  189. data : $.param({ appid: appID, sessionid: that.curatorSessionID }),
  190. onload : function(response) {
  191. callback()
  192. }
  193. });
  194. }
  195.  
  196. this.unfollowGame = function(appID, callback) {
  197. var that = this;
  198. GM_xmlhttpRequest({
  199. url : 'https://store.steampowered.com/explore/followgame/',
  200. method : 'POST',
  201. headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  202. data : $.param({ appid: appID, sessionid: that.curatorSessionID, unfollow: '1' }),
  203. onload : function(response) {
  204. callback()
  205. }
  206. });
  207. }
  208.  
  209. /**
  210. * Get the numeric ID for a Steam group
  211. */
  212. this.getGroupID = function(groupUrl, callback) {
  213. GM_xmlhttpRequest({
  214. url : groupUrl,
  215. method : "GET",
  216. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  217. onload : function(response) {
  218. var group_id = response.responseText.match(/OpenGroupChat\( \'([0-9]+)\'/);
  219. group_id = group_id === null ? null : group_id[1];
  220. callback(group_id);
  221. }
  222. })
  223. }
  224.  
  225. this.addToWishList = function(appID, callback) {
  226. var that = this;
  227. GM_xmlhttpRequest({
  228. url : 'https://store.steampowered.com/api/addtowishlist',
  229. method : 'POST',
  230. headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  231. data : $.param({ appid: appID, sessionid: that.curatorSessionID }),
  232. onload : function(response) {
  233. callback()
  234. }
  235. })
  236. }
  237.  
  238. this.removeToWishList = function(appID, callback) {
  239. var that = this;
  240. GM_xmlhttpRequest({
  241. url : 'https://store.steampowered.com/wishlist/profiles/'+that.wishlistID+'/remove/',
  242. method : 'POST',
  243. headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  244. data : $.param({ appid: appID, sessionid: that.curatorSessionID }),
  245. onload : function(response) {
  246. callback()
  247. }
  248. });
  249. }
  250. }
  251.  
  252. var initButton = $('<button style="width: 100%;" class="btn btn-xs btn-default" >初始化</button>')
  253. initButton.click(function(){
  254. initButton.text('...')
  255. steamHeper.init(function(response) {
  256. initButton.remove()
  257. if (response == false) {
  258. $('.giveaway-info-block').before($('<button style="width: 100%;" class="btn btn-xs btn-default" >全部退出</button>').click(onButtonClickLeave))
  259. }
  260. });
  261. })
  262. $('.giveaway-info-block').before(initButton)
  263. })();

QingJ © 2025

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