Sortiert Angeboote auf flaschenpost.de nach Bestpreis pro Liter.
当前为
// ==UserScript==
// @name Flaschenpost.de Bestpreis Sortierer
// @description Sortiert Angeboote auf flaschenpost.de nach Bestpreis pro Liter.
// @namespace https://www.flaschenpost.de
// @version 0.9
// @license MIT
// @match https://www.flaschenpost.de/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==
$(function() {
const list = $('.products_list_vue_container');
const listElements = $('.products_list_vue_container > .fp_product');
$(listElements).sort(function(a, b) {
function extract_price(e) {
const priceElements = $(e).find('.fp_article_pricePerUnit_deposit');
const prices = $.map(priceElements, function (e) {
const htmlText = $(e).text();
const regExMatch = htmlText.match(/\(([0-9\,]+) €\/Liter\)/);
// console.log(regExMatch);
return Number.parseFloat(regExMatch[1].replace(',', '.'));
});
// console.log(prices);
return Math.min(...prices);
}
return extract_price(a) > extract_price(b);
}).appendTo(list);
});