Guest User

Untitled

a guest
Mar 20th, 2016
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Steam Trade Autobump
  3. // @namespace http://steamcommunity.com/groups/Cannonknights
  4. // @version 4.20
  5. // @description Bumps trades on a bunch of trading sites
  6. // @match http://www.tf2outpost.com/trade*
  7. // @match http://www.csgoutpost.com/trade*
  8. // @match http://www.dotaoutpost.com/trade*
  9. // @match http://bazaar.tf/trade*
  10. // @match http://bazaar.tf/my*
  11. // @match http://csgolounge.com/mytrades*
  12. // @match http://dota2lounge.com/mytrades*
  13. // @match http://tf2tp.com/myTrades.php*
  14. // @run-at document-end
  15. // @copyright 2013+, Sir Campsalot
  16. // ==/UserScript==
  17.  
  18. (function() {
  19.  
  20. //for some reason, TF2 Trading Post bumping only works on chrome
  21. //this is why I don't actually say on userscripts that the script bumps on tf2tp
  22. //if you use chrome and want to bump trades on tf2tp, go ahead
  23. //sorry to other browser users
  24.  
  25. /*********** SETTINGS ***********/
  26.  
  27. var OutpostSingleTradeBump = true; //
  28. var OutpostBumpOnePerReload = false; //
  29. var OutpostWaitBetweenBump = true; //
  30. var OutpostTimeBetweenEachBump = 10; //
  31.  
  32. var CSGOLoungeBumpOnePerReload = true; //bump only one trade per reload on CSGO Lounge?
  33. var CSGOLoungeWaitBetweenBump = true; //wait a few seconds between each trade bump? doesn't work with CSGOLoungeBumpOnePerReload
  34. var CSGOLoungeTimeBetweenEachBump = 20; //seconds between each bump when CSGOLoungeWaitBetweenBump is true
  35.  
  36. var Dota2LoungeBumpOnePerReload = true; //
  37. var Dota2LoungeWaitBetweenBump = false; //
  38. var Dota2LoungeTimeBetweenEachBump = 10; //
  39.  
  40. var TradingPostBumpRandomTrade = true; //
  41. var TradingPostTradeToBump = 1; //
  42.  
  43. var OutpostRandomReloadTimes = true; //
  44. var BazaarRandomReloadTimes = false; //
  45. var CSGOLoungeRandomReloadTimes = false; //random page reload times on CSGOLounge?
  46. var Dota2LoungeRandomReloadTimes = false; //
  47. var TradingPostRandomReloadTimes = false; //
  48.  
  49. var OutpostReloadIfNotRandom = 1; //
  50. var OutpostMaxReloadTime = 5; //
  51. var OutpostMinReloadTime = 1; //
  52. var OutpostSingleReloadIfNotRandom = 5; //
  53. var OutpostSingleMaxReloadTime = 10; //
  54. var OutpostSingleMinReloadTime = 5; //
  55.  
  56. var BazaarReloadIfNotRandom = 5; //
  57. var BazaarMaxReloadTime = 5; //
  58. var BazaarMinReloadTIme = 1; //
  59.  
  60. var CSGOLoungeReloadIfNotRandom = 1; //if not random page reload time, reload time for all trade bump on CSGO Lounge
  61. var CSGOLoungeMaxReloadTime = 2; //max random reload time for all trade bump on CSGO Lounge
  62. var CSGOLoungeMinReloadTIme = 1; //minimum random reload time for all trade bump on CSGO Lounge
  63.  
  64. var Dota2LoungeReloadIfNotRandom = 1; //
  65. var Dota2LoungeMaxReloadTime = 5; //
  66. var Dota2LoungeMinReloadTIme = 1; //
  67.  
  68. var TradingPostReloadIfNotRandom = 1; //
  69. var TradingPostMaxReloadTime = 5; //
  70. var TradingPostMinReloadTIme = 1; //m
  71.  
  72. /******** END OF SETTINGS *******/
  73.  
  74. function randominrange(low,high) {return Math.round(Math.random()*(high-low)+low);}
  75.  
  76. function getElementsByClass(clas) {
  77. var ret = [];
  78. var elems = document.getElementsByTagName('*'), i;
  79. for (i in elems) {
  80. if((' ' + elems[i].className + ' ').indexOf(' '+clas+' ')
  81. > -1) {
  82. ret.push(elems[i]);
  83. }
  84. }
  85. return ret;
  86. }
  87.  
  88. function ParseUrl() {
  89. var parser = document.createElement('a');
  90. parser.href = undefined;
  91. return parser;
  92. }
  93.  
  94. function tptradecount() {
  95. var total = 0;
  96. var xpr = document.evaluate(".//tr/td/div[@class='trade']",document,null,XPathResult.ANY_TYPE,null);
  97. var anchor;
  98. while (anchor = xpr.iterateNext()) {
  99. if (anchor && anchor.getAttribute('id')) total++;
  100. else break;
  101. }
  102. return total;
  103. }
  104.  
  105. function notify(notify) {
  106. var divid = "stab"; //lol the acronym for steam trade autobump is stab
  107. var div = document.getElementById(divid);
  108. if (!div) {
  109. var trades;
  110. if (ParseUrl()=="http://www.tf2outpost.com/undefined" || ParseUrl()=="http://www.dotaoutpost.com/undefined" || ParseUrl()=="http://www.csgoutpost.com/undefined" || ParseUrl()=="http://bazaar.tf/undefined") trades = document.getElementById("trades");
  111. if (ParseUrl()=="http://www.tf2outpost.com/trade/undefined") trades = document.getElementById("trade");
  112. if (ParseUrl()=="http://csgolounge.com/undefined" || ParseUrl()=="http://dota2lounge.com/undefined") trades = getElementsByClass("box")[0];
  113. if (ParseUrl()=="http://tf2tp.com/undefined") trades = document.getElementById("content");
  114. var div = document.createElement("div");
  115. div.id = divid;
  116. trades.insertBefore(div, trades.childNodes[0]);
  117. }
  118. div.innerHTML = notify;
  119. }
  120.  
  121. function showstatus() {
  122. reload_time--;
  123. if (tpdelay > 0) {
  124. tpdelay--;
  125. if (tpdelay==0 && ParseUrl()=="http://tf2tp.com/undefined") acceptallalerts(false);
  126. }
  127. if (reload_time <= 0) {
  128. clearInterval(counter);
  129. location.reload();
  130. return;
  131. }
  132. var hr = Math.floor(reload_time/3600);
  133. var min = Math.floor(reload_time/60)-hr*60;
  134. var sec = reload_time-((hr*3600)+(min*60));
  135. if (ParseUrl()=="http://www.tf2outpost.com/undefined" || ParseUrl()=="http://www.dotaoutpost.com/undefined" || ParseUrl()=="http://www.csgoutpost.com/undefined" || ParseUrl()=="http://www.tf2outpost.com/trade/undefined") {
  136. if (sec<10) notify("Outpost AutoBump: Reloading page in "+min+":0"+sec);
  137. else notify("Outpost AutoBump: Reloading page in "+min+":"+sec);
  138. }
  139. if (ParseUrl()=="http://bazaar.tf/undefined") {
  140. if (sec<10) notify("Bazaar.tf AutoBump: Reloading page in "+min+":0"+sec);
  141. else notify("Bazaar.tf AutoBump: Reloading page in "+min+":"+sec);
  142. }
  143. if (ParseUrl()=="http://csgolounge.com/undefined") {
  144. if (sec<10) notify("CSGO Lounge AutoBump: Reloading page in "+min+":0"+sec);
  145. else notify("CSGO Lounge AutoBump: Reloading page in "+min+":"+sec);
  146. }
  147. if (ParseUrl()=="http://dota2lounge.com/undefined") {
  148. if (sec<10) notify("Dota 2 Lounge AutoBump: Reloading page in "+min+":0"+sec);
  149. else notify("Dota 2 Lounge AutoBump: Reloading page in "+min+":"+sec);
  150. }
  151. if (ParseUrl()=="http://tf2tp.com/undefined") {
  152. if (sec<10) notify("TF2 Trading Post AutoBump: Reloading page in "+min+":0"+sec);
  153. else notify("TF2 Trading Post AutoBump: Reloading page in "+min+":"+sec);
  154. }
  155. }
  156.  
  157. function acceptallalerts (accept) {
  158. if (accept) {
  159. unsafeWindow.confirm = function() {return true;}
  160. unsafeWindow.alert = null;
  161. }
  162. else {
  163. unsafeWindow.confirm = conf;
  164. unsafeWindow.alert = aler;
  165. }
  166. }
  167.  
  168. function bump_trades() {
  169. var xpr, anchor;
  170. if (ParseUrl()=="http://www.tf2outpost.com/undefined" || ParseUrl()=="http://www.dotaoutpost.com/undefined" || ParseUrl()=="http://www.csgoutpost.com/undefined" || ParseUrl()=="http://www.tf2outpost.com/trade/undefined") {
  171. var isUser, close_button;
  172. close_button = getElementsByClass("state_toggle")[0];
  173. if (close_button) {
  174. if (close_button.getAttribute("data-tipsy") == "Close Trade") isUser = true;
  175. }
  176. else isUser = false;
  177. if (!isUser) return;
  178. xpr = document.evaluate(".//li/a[@class='trade_bump']/div[@class='icon_bump']", document, null, XPathResult.ANY_TYPE, null);
  179. while (anchor = xpr.iterateNext()) {
  180. anchor = anchor.parentNode;
  181. if (anchor.getAttribute('data-tradeid')) break;
  182. }
  183. if (anchor && anchor.getAttribute('data-tradeid')) {
  184. anchor.click();
  185. if (!OutpostBumpOnePerReload) {
  186. if (OutpostWaitBetweenBump) setTimeout(bump_trades,(OutpostTimeBetweenEachBump*1000));
  187. else setTimeout(bump_trades,5);
  188. }
  189. }
  190. }
  191. if (ParseUrl()=="http://csgolounge.com/undefined" || ParseUrl()=="http://dota2lounge.com/undefined") {
  192. xpr = document.evaluate(".//div[@class='tradepoll']/div[@class='tradeheader']/a[@class='buttonright']", document, null, XPathResult.ANY_TYPE, null);
  193. anchor = xpr.iterateNext();
  194. if (anchor && anchor.getAttribute('onclick')) {
  195. anchor.click();
  196. if (ParseUrl()=="http://csgolounge.com/undefined" && !CSGOLoungeBumpOnePerReload) {
  197. if (CSGOLoungeWaitBetweenBump) setTimeout(bump_trades,(CSGOLoungeTimeBetweenEachBump*1000));
  198. else setTimeout(bump_trades,5);
  199. }
  200. if (ParseUrl()=="http://dota2lounge.com/undefined" && !Dota2LoungeBumpOnePerReload) {
  201. if (Dota2LoungeWaitBetweenBump) setTimeout(bump_trades,(Dota2LoungeTimeBetweenEachBump*1000));
  202. else setTimeout(bump_trades,5);
  203. }
  204. }
  205. }
  206. if (ParseUrl()=="http://tf2tp.com/undefined") {
  207. var tf2tpttb;
  208. if (TradingPostBumpRandomTrade) tf2tpttb = randominrange(1,tptradecount());
  209. else {
  210. if (TradingPostTradeToBump>tptradecount()) tf2tpttb = tptradecount();
  211. else tf2tpttb = TradingPostTradeToBump;
  212. }
  213. acceptallalerts(true);
  214. xpr = document.evaluate(".//div[@class='trade']/h5/a[@class='bumpAjaxLink']", document, null, XPathResult.ANY_TYPE, null);
  215. for (var ttb = tf2tpttb; (ttb>0 && ttb<=tptradecount()); ttb--) anchor = xpr.iterateNext();
  216. if (anchor) anchor.click();
  217. }
  218. reload_time = RELOAD_MINUTES*60;
  219. counter = setInterval(showstatus, 1000);
  220. }
  221.  
  222. if (!OutpostSingleTradeBump && ParseUrl()=="http://www.tf2outpost.com/trade/undefined") return;
  223. var reload_time, counter, RELOAD_MINUTES;
  224. var conf = unsafeWindow.confirm;
  225. var aler = unsafeWindow.alert;
  226. var tpdelay = 2;
  227. if (ParseUrl()=="http://www.tf2outpost.com/undefined" || ParseUrl()=="http://www.dotaoutpost.com/undefined" || ParseUrl()=="http://www.csgoutpost.com/undefined") {
  228. if (OutpostRandomReloadTimes) RELOAD_MINUTES = randominrange(OutpostMinReloadTime,OutpostMaxReloadTime);
  229. else RELOAD_MINUTES = OutpostReloadIfNotRandom;
  230. }
  231. if (ParseUrl()=="http://www.tf2outpost.com/trade/undefined") {
  232. if (OutpostRandomReloadTimes) RELOAD_MINUTES = randominrange(OutpostSingleMinReloadTime,OutpostSingleMaxReloadTime);
  233. else RELOAD_MINUTES = OutpostSingleReloadIfNotRandom;
  234. }
  235. if (ParseUrl()=="http://bazaar.tf/undefined") {
  236. if (BazaarRandomReloadTimes) RELOAD_MINUTES = randominrange(BazaarMinReloadTIme,BazaarMaxReloadTime);
  237. else RELOAD_MINUTES = BazaarReloadIfNotRandom;
  238. }
  239. if (ParseUrl()=="http://csgolounge.com/undefined") {
  240. if (CSGOLoungeRandomReloadTimes) RELOAD_MINUTES = randominrange(CSGOLoungeMinReloadTIme,CSGOLoungeMaxReloadTime);
  241. else RELOAD_MINUTES = CSGOLoungeReloadIfNotRandom;
  242. }
  243. if (ParseUrl()=="http://dota2lounge.com/undefined") {
  244. if (Dota2LoungeRandomReloadTimes) RELOAD_MINUTES = randominrange(Dota2LoungeMinReloadTIme,Dota2LoungeMaxReloadTime);
  245. else RELOAD_MINUTES = Dota2LoungeReloadIfNotRandom;
  246. }
  247. if (ParseUrl()=="http://tf2tp.com/undefined") {
  248. if (TradingPostRandomReloadTimes) RELOAD_MINUTES = randominrange(TradingPostMinReloadTIme,TradingPostMaxReloadTime);
  249. else RELOAD_MINUTES = TradingPostReloadIfNotRandom;
  250. }
  251. bump_trades();
  252. }).call(this);
RAW Paste Data