eNameX

易名价格醒目脚本,防大佬标错价,防米农秒错米。坑同行的木有小JJ!

  1. // ==UserScript==
  2. // @name eNameX
  3. // @namespace http://xiami.im/
  4. // @version 0.1
  5. // @description 易名价格醒目脚本,防大佬标错价,防米农秒错米。坑同行的木有小JJ!
  6. // @author xiami.im
  7. // @require http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js
  8. // @include http://*.ename.com/*
  9. // @exclude http://*.ename.com/*inquiry*
  10. // @exclude http://*.ename.com/book/expired*
  11. // @grant none
  12. // ==/UserScript==
  13. //Sell domains
  14. $(document).ready(function () {
  15. //Add commas to the prices
  16. function addComma(num) {
  17. num = num.toString().split('').reverse().join('').replace(/(\d{3})/g, '$1,').replace(/\,$/, '').split('').reverse().join('');
  18. return num;
  19. }
  20. //Farmatting the prices
  21.  
  22. function formatPrice(priceNum) {
  23. var priceLen = priceNum.toString().length;
  24. if (priceLen > 4) {
  25. var tt = parseInt(priceNum) / 10000;
  26. var t3 = tt.toPrecision(3);
  27. var t4 = tt.toPrecision(4);
  28. if (priceLen > 8) {
  29. tip = (parseInt(priceNum.substr(3, priceLen - 3)) ? '~' : '') + parseFloat((tt / 10000).toPrecision(3)) + ' 亿';
  30. } else {
  31. tip = (parseInt(priceNum.substr(3, priceLen - 3)) ? '~' : '') + ((priceLen == 8) ? addComma(t4) : parseFloat(t3)) + ' 万';
  32. }
  33. } else {
  34. tip = addComma(priceNum);
  35. }
  36. return tip;
  37. }
  38. //Replace default character with price dom
  39.  
  40. $('table.site_com_table tr:gt(0)').each(function () {
  41. var priceTd = $(this).children('td:eq(3)');
  42. priceTd.html(priceTd.html().replace('元', ''));
  43. priceTd.append('<span class=priceStand></span>');
  44. priceTd.children('.priceStand').css({
  45. color: 'red',
  46. 'letter-spacing': '1px'
  47. });
  48. });
  49. //Keyup listener
  50. $('table.site_com_table tr:gt(0)').each(function () {
  51. var priceTd = $(this).children('td:eq(3)');
  52. priceTd.children('input').keyup(function () {
  53. var priceNum = priceTd.children('input').val();
  54. formatPrice(priceNum);
  55. priceTd.children('.priceStand').text('¥' + tip);
  56. });
  57. //Bat Keyup listener
  58. var priceBat = $('table.site_com_table tr:eq(1)').children('td:eq(3)');
  59. priceBat.children('input').keyup(function () {
  60. var priceNum = priceBat.children('input').val();
  61. formatPrice(priceNum);
  62. $('table.site_com_table tr:gt(0)').each(function () {
  63. $(this).children('td:eq(3)').children('.priceStand').text('¥' + tip);
  64. });
  65. });
  66. });
  67. //Buy domains
  68. $('.bid_domain').append('<span class="priceTip"></span>');
  69. var priceValue = formatPrice($('#askingPrice').text());
  70. if ($('#askingPrice').text() == '1') {
  71. $('.priceTip').text('1元拍');
  72. } else {
  73. $('.priceTip').text('¥' + priceValue);
  74. }
  75. $('.priceTip').css({
  76. color: 'red'
  77. });
  78. $('table.com_table tr:gt(0)').each(function () {
  79. if ($(this).children('td:eq(7)').length > 0) {
  80. var priceList = $(this).children('td:eq(5)');
  81. } else if ($(this).children('td:eq(6)').length > 0) {
  82. priceList = $(this).children('td:eq(4)');
  83. }
  84. priceList.text('¥' + formatPrice(priceList.text().replace('元', ''))).css({
  85. color: 'red'
  86. });
  87. });
  88. });