Greasy Fork is available in English.
Sorts search results by item price properly with shipping costs included, enhances item pages
I suggest some changes to make it work on others concurrency and chrome compatibility. (I dont know a better method to share differences, maybe just update a file?)
@@ -26,9 +26,8 @@
var sortingnow = false;
var tnum = 0;
var itemstype = 2;
+var valuteSymb = '€';
var GM_SuperValue = new function () {
var JSON_MarkerStr = 'json_val: ';
@@ -106,16 +105,16 @@
}
if (typeof varValue == "string") {
//--- Is it a JSON value?
+ let regxp = new RegExp ('^' + JSON_MarkerStr + '(.+) *'+ valuteSymb);
- let regxp = new RegExp ('^' + JSON_MarkerStr + '(.+)$');
var m = varValue.match (regxp);
if(m && m.length > 1) {
varValue = JSON.parse ( m[1] );
return varValue;
}
+ let regxp2 = new RegExp ('^' + FunctionMarker + '((?:.|\n|\r)+) *'+valuteSymb);
- let regxp2 = new RegExp ('^' + FunctionMarker + '((?:.|\n|\r)+)$');
let m2 = varValue.match (regxp2);
if (m2 && m2.length > 1) {
varValue = eval('(' + m2[1] + ')');
return varValue;
@@ -541,47 +540,46 @@
}
}
function formatPrice(text){
+ if (valuteSymb != '$'){ text=text.replace('.',''); text=text.replace(',','.');}
+ return [text.substring(0, text.indexOf(valuteSymb) + 1), parseFloat(text.substring(text.indexOf(valuteSymb) + 1))];
- return [text.substring(0, text.indexOf('$') + 1), parseFloat(text.substring(text.indexOf('$') + 1))];
}
function findPrice(listitem){
if(itemstype == 1){
let pricerow = listitem.querySelector('div:nth-child(3) > div > div');
if(pricerow){
+ if(pricerow.innerHTML.match(new RegExp ('^[^'+valuteSymb+']*'+valuteSymb+' *\\d+[.,]?\\d* *[^<]*$'))){
- if(pricerow.innerHTML.substring(3).startsWith('$')){
return formatPrice(pricerow.innerText).concat(pricerow);
}
else{
let alldivs = listitem.querySelectorAll("div > div");
for (let i = 0; i < alldivs.length; i++) {
+ if(alldivs[i].innerHTML.match(new RegExp ('^[^'+valuteSymb+']*'+valuteSymb+' *\\d+[.,]?\\d* *[^<]*$'))){
- if(alldivs[i].innerHTML.substring(3).startsWith('$')){
return formatPrice(alldivs[i].innerText).concat(alldivs[i]);
}
}
}
}
else{
let alldivs = listitem.querySelectorAll("div > div");
for (let i = 0; i < alldivs.length; i++) {
+ if(alldivs[i].innerHTML.match(new RegExp ('^[^'+valuteSymb+']*'+valuteSymb+' *\\d+[.,]?\\d* *[^<]*$'))){
- if(alldivs[i].innerHTML.substring(3).startsWith('$')){
return formatPrice(alldivs[i].innerText).concat(alldivs[i]);
}
}
}
}
else if(itemstype == 2){
let pricerow = listitem.querySelector('div:nth-child(2) > div:nth-child(2)');
if(pricerow){
+ if(pricerow.innerText.match(new RegExp ('^[^'+valuteSymb+']*'+valuteSymb+' *\\d+[.,]?\\d* *[^<]*$'))){
- if(pricerow.innerText.substring(3).startsWith('$')){
return formatPrice(pricerow.innerText).concat(pricerow);
}
else{
let alldivs = listitem.querySelectorAll("div > div");
for (let i = 0; i < alldivs.length; i++) {
+ if(alldivs[i].innerText.match(new RegExp ('^[^'+valuteSymb+']*'+valuteSymb+' *\\d+[.,]?\\d* *[^<]*$'))){
- if(alldivs[i].innerText.substring(3).startsWith('$')){
return formatPrice(alldivs[i].innerText).concat(alldivs[i]);
}
}
}
@@ -591,9 +589,9 @@
}
else{
let alldivs = listitem.querySelectorAll("div > div");
for (let i = 0; i < alldivs.length; i++) {
+ if(alldivs[i].innerText.match(new RegExp ('^[^'+valutesSymb+']*'+valuteSymb+'\d+[.,]?\d* *[?<]*$'))){
- if(alldivs[i].innerText.substring(3).startsWith('$')){
return formatPrice(alldivs[i].innerText).concat(alldivs[i]);
}
}
}
@@ -629,11 +627,9 @@
function formatShipping(text){
if(text.innerHTML.startsWith('+ Shipping')){
+ let tmpText = text.innerHTML;
+ if (valuteSymb != '$'){ tmpText=tmpText.replace('.',''); tmpText=tmpText.replace(',','.');}
+ text = parseFloat(tmpText.substring(tmpText.indexOf(valuteSymb) + 1));
- text = parseFloat(text.innerText.substring(text.innerText.indexOf('$') + 1));
return text;
}
else if(text.innerHTML.startsWith('Free Shipping')){
return 0;
@@ -692,9 +688,9 @@
let shipping = await findShipping(listitem);
let totalPrice = price[1];
if(shipping){
totalPrice += shipping;
+ price[2].innerHTML = price[2].innerHTML + " (+ "+valuteSymb + shipping + " Shipping)";
- price[2].innerHTML = price[2].innerHTML + " (+ $" + shipping + " Shipping)";
}
totalPrice = totalPrice.toFixed(2);
var finalcostdiv = document.createElement('div');
finalcostdiv.style = "display: table-row;";
@@ -907,18 +903,14 @@
}
function fakeScrollDown(){
setTimeout((function(){
+ window.scrollBy({
+ top: window.innerHeight,
+ left: 0,
+ behavior: 'auto'
+ });
+ if(window.scrollY < window.document.body.scrollHeight-window.window.innerHeight){
- window.scrollByPages(1);;
- if(window.scrollY < window.scrollMaxY){
fakeScrollDown();
}
else{
+ setTimeout(()=> window.scrollTo(0,0), 400);
- window.scrollTo(0,0);
}
}),100);
}
@@ -928,16 +920,14 @@
itempageshipping = itempageshipping.innerText;
if(itempageshipping.indexOf('Free Shipping') != -1){
itempageshipping = '0.00';
}
+ if (valuteSymb != '$'){ itempageshipping=itempageshipping.replace('.',''); itempageshipping=itempageshipping.replace(',','.');}
+ itempageshipping = parseFloat(itempageshipping.substring(itempageshipping.indexOf(valuteSymb)+1).trimEnd());
- itempageshipping = parseFloat(itempageshipping.substring(itempageshipping.indexOf('$')+1).trimEnd());
var itempageprice = document.querySelector('.product-price-value');
if(itempageprice){
itempageprice = itempageprice.innerText;
+ if (valuteSymb != '$'){ itempageprice=itempageprice.replace('.',''); itempageprice=itempageprice.replace(',','.');}
+ var preprice = itempageprice.substring(itempageprice.indexOf(':')+1, itempageprice.indexOf(valuteSymb)+1);
+ itempageprice = parseFloat(itempageprice.substring(itempageprice.indexOf(valuteSymb)+1).trimEnd());
- var preprice = itempageprice.substring(itempageprice.indexOf(':')+1, itempageprice.indexOf('$')+1);
- itempageprice = parseFloat(itempageprice.substring(itempageprice.indexOf('$')+1).trimEnd());
var itempagetotal = parseFloat(itempageshipping + itempageprice).toFixed(2).toString();
var finalcostpretext = document.createElement('span');
finalcostpretext.className = 'total-pretext';
finalcostpretext.innerHTML = "Total: " + preprice + itempagetotal;
Aliexpress keep changing their website code to break the plugin.
I've just updated it. Should work now.
Also added the wishlist feature they broke from v1.*. It now includes an image similarity search. Config menu is back also.
They recently got rid of all classnames and ids on everything, so now it doesn't rely on them.
Theoretically it should be harder for them to break this version, and if they do, it should be easy to patch.