WoW Remote AH Enhancement

WoW Remote Auction House Enhancements

  1. // ==UserScript==
  2. // @name WoW Remote AH Enhancement
  3. // @version 0.5.0
  4. // @description WoW Remote Auction House Enhancements
  5. // @author Scott Mundorff
  6. // @match https://*.battle.net/wow/*/vault/character/auction/*
  7. // @grant none
  8. // @require http://code.jquery.com/jquery-latest.js
  9. // @namespace http://tampermonkey.net/
  10. // ==/UserScript==
  11. var idleTime = 0;
  12. $(document).ready(function(){
  13. //Increment the idle time counter every minute.
  14. var idleInterval = setInterval(timerIncrement, 60000); // 1 minute
  15.  
  16. //Zero the idle timer on mouse movement.
  17. $(this).mousemove(function (e) {
  18. idleTime = 0;
  19. });
  20. $(this).keypress(function (e) {
  21. idleTime = 0;
  22. });
  23. if(Auction.page == "browse"){
  24. if(Storage.initialized && JSON.parse){
  25. var storage = Storage.get("wow.auctions.inventory");
  26. AuctionBrowse.Inventory = JSON.parse(storage);
  27. }
  28. AuctionBrowse.Items = [];
  29. $("div.auction-house").children("div.table").find("td.item").parent().each(function(){
  30. var newItem = new AuctionItem(this);
  31. AuctionBrowse.Items.push(newItem);
  32. });
  33. AuctionBrowse.Filter = function(filter){
  34. var price = /\/(\d+)g/gi;
  35. var priceMatch = price.exec(filter);
  36. var minPrice = Auction.deformatMoney(priceMatch[1],0,0);
  37. priceMatch = price.exec(filter);
  38. var maxPrice = Auction.deformatMoney(priceMatch[1],0,0);
  39. $(AuctionBrowse.Items).each(function(){
  40. if(minPrice && this.buyoutppi < minPrice) this.Remove();
  41. if(maxPrice && this.buyoutppi > maxPrice) this.Remove();
  42. });
  43. };
  44.  
  45. var auctioneer = Storage.get("wow.auctions.auctioneer");
  46. if(auctioneer){
  47. var auctioneerCache = JSON.parse(auctioneer);
  48. }else{
  49. var auctioneerCache = {
  50. items:null,
  51. };
  52. }
  53.  
  54. Storage.set("wow.auctions.auctioneer", JSON.stringify(auctioneerCache));
  55. /*
  56. $("div.profile-sidebar-inner").css("height","auto");
  57. $("ul.profile-sidebar-menu > li").css("float","left");
  58. $("div.profile-sidebar-crest").css("display","none");
  59. $("div.profile-contents").css("width","");
  60. $("div.profile-contents").css("float","");
  61. */
  62. $("#header").css("padding-top","");
  63. $("#header .search-bar").css("position","");
  64. }else if(Auction.page == "create"){
  65. if (Storage.initialized && JSON.parse) {
  66. // get player inventory
  67. Storage.set("wow.auctions.inventory", JSON.stringify(AuctionCreate.items));
  68. }
  69. $('#similar-auctions').on("DOMSubtreeModified",function(){
  70. if($("#similar-auctions .similar-items").length){
  71. $("#similar-auctions .similar-items .table tr .price").click(undercut);
  72. $("#similar-auctions .similar-items .table tr .price").first().click();
  73. }
  74. });
  75. }
  76. // Auction.page
  77. Auction.toasts.AHEnhanced = "AH Enhanced Loaded";
  78. var message = "";
  79. if (!("Notification" in window)) {
  80. Auction.toast("AHEnhanced",5000,"This browser does not support desktop notification");
  81. }else{
  82. if(Notification.permission !== 'denied' && Notification.permission !== "granted")
  83. {
  84. Notification.requestPermission(function(){
  85. var n = new Notification("Desktop notifications enabled");
  86. });
  87. }
  88. if (Notification.permission === "granted") {
  89. Auction.toast("AHEnhanced",5000,"Desktop notifications enabled");
  90. // If it's okay, let's replace toasts with notifications
  91. Toast.show = function(content, options){
  92. var n = new Notification(content);
  93. setTimeout(n.close.bind(n),options.timer);
  94. };
  95. }else{
  96. Auction.toast("AHEnhanced",5000,"Desktop notifications disabled");
  97. }
  98. }
  99. });
  100.  
  101. function undercut(){
  102. // select per item pricing
  103. $("#form-priceType").val("perItem");
  104. var money = GetPrice(this);
  105. if($(this).parent().children().first().text() != Auction.character.name)
  106. money -= 1;
  107. AuctionCreate.setStarting(money * 0.98);
  108. AuctionCreate.setBuyout(money);
  109. }
  110.  
  111. function GetPrice(item){
  112. var gold = $(item).children(".icon-gold").first().text();
  113. var silver = $(item).children(".icon-silver").first().text();
  114. var copper = $(item).children(".icon-copper").first().text();
  115. return Auction.deformatMoney(gold, silver, copper);
  116. }
  117.  
  118. function ParseILvl(item){
  119. var level = $(item).children("td.level");
  120. var minLvl = $(level).children("div").children("strong").first().text();
  121. var iLvl = $(level).children("div").children("strong").last().text();
  122. $(level).text(minLvl + " / i" + iLvl);
  123. }
  124.  
  125. function timerIncrement() {
  126. idleTime = idleTime + 1;
  127. if (idleTime > 5) { // 20 minutes
  128. window.location.reload();
  129. }
  130. }
  131.  
  132. var AuctionItem = function(item){
  133. this.auctionID = item.id.replace("auction-","");
  134. this.itemID = $(item).children("td.item").children("a.icon-frame").attr("href").replace("/wow/en/item/","");
  135. var level = $(item).children("td.level");
  136. this.html = item;
  137. this.minLvl = $(level).children("div").children("strong").first().text();
  138. this.iLvl = $(level).children("div").children("strong").last().text();
  139. $(level).text(this.minLvl + " / i" + this.iLvl);
  140.  
  141. var price = $(item).children("td.price");
  142. this.bid = GetPrice($(price).children("div.price-bid"));
  143. this.buyout = GetPrice($(price).children("div.price-buyout"));
  144. this.quantity = $(item).children("td.quantity").text();
  145. this.buyoutppi = this.buyout / this.quantity;
  146. if(AuctionBrowse.Inventory[this.itemID])
  147. {
  148. this.inInventory = AuctionBrowse.Inventory[this.itemID].q0;
  149. if(this.inInventory > 0){
  150. $("<span>| Inv: " + this.inInventory + "</span>").insertBefore($(item).children("td.item").children().last());
  151. }
  152. }
  153. if(false){
  154. $(item).children("td.price").children("div.price-buyout").css("background-color","gainsboro");
  155. }
  156. this.Remove = function(){
  157. $(this.html).css("display","none");
  158. };
  159. };
  160.