WRMdoc™ Helper

This simple script will provide easier buying from WRMdoc™ [http://bit.ly/WRMdocTM].

当前为 2014-09-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WRMdoc™ Helper
  3. // @namespace WRMdocHelper
  4. // @description This simple script will provide easier buying from WRMdoc™ [http://bit.ly/WRMdocTM].
  5. // @require http://code.jquery.com/jquery-2.0.3.min.js
  6. // @include *erepublik.com/*/main/messages*
  7. // @include *erepublik.com/*/economy/market/*?*
  8. // @version 5.2
  9. // ==/UserScript==
  10.  
  11. function CustomOffer() {
  12. var t, e, n, l
  13. if ($(".success_message").length <= 0 && $(".error_message").length <= 0) {
  14. localStorage.BuyingLog = "";
  15. localStorage.BuyingTime = "";
  16. $("#marketplace table").before("<h1><a style='color:#009925;'>Step 1)</a> Buy desired quantity</h1>")
  17. if (t = window.location.href, e = t.split("?")[1], "undefined" == typeof e) return
  18. if (r = "true" == e.split("customOffer=")[1].split("&")[0] ? !0 : !1, i = parseInt(e.split("sellerId=")[1].split("&")[0]), s = decodeURI(e.split("sellerName=")[1].split("&")[0]), o = parseInt(e.split("offerId=")[1].split("&")[0]), u = parseInt(e.split("offerAmount=")[1].split("&")[0]), a = e.split("offerPrice=")[1], !r || isNaN(i) || isNaN(u) || isNaN(a)) return
  19. $("#marketplace table tbody tr:not(:first)").remove(), $("#marketplace .pager").remove(), n = $("#marketplace table tbody tr:first"), $(".m_product", n).attr("id", "productId_" + o), $(".m_provider a", n).attr("href", "/en/citizen/profile/" + i), $(".m_provider a", n).text(s), $(".m_stock", n).text(u), $(".m_price strong:first", n).text(a.split(".")[0]), l = $(".m_price sup strong", n), $(".m_price sup", n).html("." + a.split(".")[1] + " " + l[0].outerHTML), $(".m_quantity input", n).attr("id", "amount_" + o), $(".m_quantity input", n).attr("maxlength", "6"), $(".m_buy a", n).attr("id", o), $(".m_buy a", n).attr("data-max", u)
  20. }
  21. else if ($(".success_message").length > 0) {
  22. var eRepublikDay = $("span.eday").text().trim();
  23. var eRepublikTime = $("span#live_time.time").text();
  24. var t = window.location.href;
  25. var e = t.split("?")[1];
  26. var SellerNick = decodeURI(e.split("sellerName=")[1].split("&")[0]);
  27. var SellerID = parseInt(e.split("sellerId=")[1].split("&")[0]);
  28. localStorage.BuyingLog = $(".success_message").text().trim();
  29. localStorage.BuyingTime = eRepublikDay + " | " + eRepublikTime + " | WRMdoc";
  30. localStorage.ID = SellerID;
  31. $("#marketplace table").eq(0).before("<h1><a style='color:#009925;'>Step 2)</a> Send log to <a href='/en/main/messages-compose/" + SellerID + "' target='_blank'>" + SellerNick + "</a></h1>")
  32. }
  33. }
  34.  
  35. function MessageHelper() {
  36. $("#citizen_subject").val(localStorage.BuyingTime);
  37. $("#citizen_message").val(localStorage.BuyingLog);
  38. localStorage.clear();
  39. }
  40.  
  41. $(document).ready(function () {
  42. if (window.location.href.indexOf("customOffer=true") > 0) {
  43. CustomOffer();
  44. }
  45. else if (window.location.href.indexOf("messages") > 0 && window.location.href.indexOf(localStorage.ID) > 0) {
  46. MessageHelper();
  47. }
  48. });