eBay Collection Sorter

Sorts Collections on eBay

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        eBay Collection Sorter
// @namespace   http://www.facebook.com/Tophness
// @description Sorts Collections on eBay
// @include     http://*ebay.tld/cln/*
// @version     1
// @grant       none
// ==/UserScript==

var prevY = 0;
windowscroll = setInterval(doscroll, 800);
function doscroll() {
	if (window.scrollMaxY !== prevY) {
		prevY = window.scrollMaxY;
		window.scrollTo(0, window.scrollMaxY);
	} else {
		clearInterval(windowscroll);
		window.scrollTo(0, 0);
		doSort();
	}
}

function doSort() {
	var prices = new Array();
	var items = document.getElementsByClassName('collection-gallery')[0].childNodes;
	for (var i = 0; i < items.length; ++i) {
		if (items[i].tagName == 'DIV') {
			var nitems = items[i].getElementsByTagName('div');
			for (var j = 0; j < nitems.length; ++j) {
				if (nitems[j].className == 'itemPrice') {
					if (nitems[j].textContent.indexOf('$') != -1) {
						var price = nitems[j].textContent.substring(nitems[j].textContent.indexOf('$') + 1);
						prices.push({
							price : price,
							el : items[i]
						});
					}
				}
			}
		}
	}

	prices.sort(function (a, b) {
		return a.price - b.price;
	});

	for (var ni = 0; ni < items.length; ++ni) {
		if (items[ni].tagName == 'DIV') {
			document.getElementsByClassName('collection-gallery')[0].removeChild(items[ni]);
		}
	}

	for (var nj = 0; nj < prices.length; nj++) {
		document.getElementsByClassName('collection-gallery')[0].appendChild(prices[nj].el);
	}
}