eBay Collection Sorter

Sorts Collections on eBay

  1. // ==UserScript==
  2. // @name eBay Collection Sorter
  3. // @namespace http://www.facebook.com/Tophness
  4. // @description Sorts Collections on eBay
  5. // @include http://*ebay.tld/cln/*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var prevY = 0;
  11. windowscroll = setInterval(doscroll, 800);
  12. function doscroll() {
  13. if (window.scrollMaxY !== prevY) {
  14. prevY = window.scrollMaxY;
  15. window.scrollTo(0, window.scrollMaxY);
  16. } else {
  17. clearInterval(windowscroll);
  18. window.scrollTo(0, 0);
  19. doSort();
  20. }
  21. }
  22.  
  23. function doSort() {
  24. var prices = new Array();
  25. var items = document.getElementsByClassName('collection-gallery')[0].childNodes;
  26. for (var i = 0; i < items.length; ++i) {
  27. if (items[i].tagName == 'DIV') {
  28. var nitems = items[i].getElementsByTagName('div');
  29. for (var j = 0; j < nitems.length; ++j) {
  30. if (nitems[j].className == 'itemPrice') {
  31. if (nitems[j].textContent.indexOf('$') != -1) {
  32. var price = nitems[j].textContent.substring(nitems[j].textContent.indexOf('$') + 1);
  33. prices.push({
  34. price : price,
  35. el : items[i]
  36. });
  37. }
  38. }
  39. }
  40. }
  41. }
  42.  
  43. prices.sort(function (a, b) {
  44. return a.price - b.price;
  45. });
  46.  
  47. for (var ni = 0; ni < items.length; ++ni) {
  48. if (items[ni].tagName == 'DIV') {
  49. document.getElementsByClassName('collection-gallery')[0].removeChild(items[ni]);
  50. }
  51. }
  52.  
  53. for (var nj = 0; nj < prices.length; nj++) {
  54. document.getElementsByClassName('collection-gallery')[0].appendChild(prices[nj].el);
  55. }
  56. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址