TF2Outpost AutoBump

Bumps trade on TF2 Outpost

  1. // ==UserScript==
  2. // @name TF2Outpost AutoBump
  3. // @version 1.0
  4. // @description Bumps trade on TF2 Outpost
  5. // @include http://www.tf2outpost.com/trades
  6. // @run-at document-end
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/5246
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. var RELOAD_MINUTES = 31; // reload every 31 minutes
  13. var divid = "tf2oab";
  14. var reload_time, counter;
  15.  
  16. function notify(notify) {
  17. var div = document.getElementById(divid);
  18. if (!div) {
  19. var trades = document.getElementById("trades");
  20. var div = document.createElement("div");
  21. div.id = divid;
  22. trades.insertBefore(div, trades.childNodes[0]);
  23. }
  24. div.innerHTML = notify;
  25. }
  26. /*
  27. Called by the JS Interval counter to reload the page after reload_time
  28. */
  29. function showstatus() {
  30. reload_time -= 1;
  31. if (reload_time <= 0)
  32. {
  33. clearInterval(counter);
  34. location.reload();
  35. return;
  36. }
  37. var min = Math.floor(reload_time/60);
  38. var sec = reload_time - min*60;
  39. notify("TF2 Outpost AutoBump: Reloading page in " +min+ " minutes and "+sec+" seconds...");
  40. }
  41. function color_anchor(anchor, apply) {
  42. anchor.parentNode.parentNode.parentNode.parentNode.style.border = apply?"1px solid red":"none";
  43. }
  44. function bump_trades() {
  45. var xpr = document.evaluate(".//li/a[@class='trade_bump']/div[@class='icon_bump']", document, null, XPathResult.ANY_TYPE, null);
  46. var anchor;
  47. while (anchor = xpr.iterateNext()) {
  48. anchor = anchor.parentNode;
  49. if (anchor.getAttribute('data-tradeid'))
  50. break;
  51. }
  52. if (anchor && anchor.getAttribute('data-tradeid')) {
  53. anchor.scrollIntoView();
  54. color_anchor(anchor, true);
  55. setTimeout(function(){
  56. color_anchor(anchor, false);
  57. anchor.click();
  58. setTimeout(bump_trades, 500);
  59. }, 500);
  60. } else {
  61. reload_time = RELOAD_MINUTES*60;
  62. window.scrollTo(0,0);
  63. counter = setInterval(showstatus, 1000);
  64. }
  65. }
  66. bump_trades();
  67. }).call(this);