eBay Total Auction Price

Add the total eBay auction price + shipping = total in the auction listing

目前为 2015-03-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name eBay Total Auction Price
  3. // @namespace https://greasyfork.org/en/users/9709-ecofriend
  4. // @version 2015.03.17
  5. // @author ecofriend
  6. // @description Add the total eBay auction price + shipping = total in the auction listing
  7. // @include http://www.ebay.co.uk/sch/*
  8. // @run-at document-end
  9. // @grant GM_info
  10. // ==/UserScript==
  11.  
  12.  
  13. function qs(a){
  14. var scope = a.cn || document;
  15. if (a.all === true){
  16. var qsa;
  17. if (a.ar === true){
  18. qsa = Array.prototype.slice.call(scope.querySelectorAll(a.se));
  19. }
  20. else {
  21. qsa = scope.querySelectorAll(a.se);
  22. }
  23. return qsa;
  24. }
  25. else {
  26. return scope.querySelector(a.se);
  27. }
  28. }
  29.  
  30. function findMatch(string, regex, index){
  31. if (string === null) return null;
  32. index = index || 1;
  33. var m = string.match(regex);
  34. return (m) ? (index=='all' ? m : (m[index] ? m[index] : m[0])) : null;
  35. }
  36.  
  37. var lvi = qs({se:'#ListViewInner > li', all:true, ar:true});
  38. if (lvi){
  39. for (var i=0; lvi[i]; i++){
  40. var pr = qs({se:'.lvprice span', cn:lvi[i]}),
  41. pp = qs({se:'.fee', cn:lvi[i]});
  42. if (pr && pp){
  43. var cur = findMatch(pr.textContent, /(.)\d+\.\d+/);
  44. var tot = parseFloat(findMatch(pr.textContent, /(\d+\.\d+)/)) +
  45. parseFloat(findMatch(pp.textContent, /(\d+\.\d+)/));
  46. pp.innerHTML = pp.textContent +'<br>= '+ cur + tot.toFixed(2);
  47. }
  48. }
  49. }