alike03 / allkeyshop.com Real Prices

// ==UserScript==
// @name        allkeyshop.com Real Prices
// @description Calculates Prices including payment fees
// @author      alike03
// @namespace   ks_real_price
// @match       *://www.allkeyshop.com/blog/*
// @version     1.3
// @icon        https://www.allkeyshop.com/favicon.ico
// @updateURL   https://openuserjs.org/meta/alike03/allkeyshop.com_Real_Prices.meta.js
// @supportURL  https://openuserjs.org/scripts/alike03/allkeyshop.com_Real_Prices/issues
// @downloadURL https://openuserjs.org/src/scripts/alike03/allkeyshop.com_Real_Prices.user.js
// @require     https://code.jquery.com/jquery-3.6.0.slim.min.js
// @copyright   2021, alike03 (https://openuserjs.org/users/alike03)
// @license     MIT
// ==/UserScript==
/* jshint esversion: 6 */
/* globals $, jQuery */

window.onload = function () {
  if ($('.offers').length) {
    var checkExist = setInterval(() => {
      if ($('.offers-table-row').length) {
        clearInterval(checkExist);
        startScript();
      }
    }, 100); // check every 100ms

    setTimeout(() => {
      clearInterval(checkExist);
    }, 5000); // stop after 5000ms
  }
}

function startScript() {

  $('#offers_table').children().each(function (i, e) {
    if (i != 0) {
      let price = $(e).find('.x-offer-price').text();

      $(e).find('.fees-value:not(.x-offer-fee-shield)').each(function (j, f) {
        let fee = parseFloat($(f).text());
        fee = isNaN(fee) ? 0 : fee;
        let priceSum = parseFloat(price) + parseFloat(fee);
        $(f).text(fee + ' | ' + (priceSum).toFixed(2) + '€');
        $(f).removeClass('offer-fee-none');
        // set Order
        let currentOrder = $(f).closest('.offers-table-row').css('order');
        let newOrder = (priceSum * 100).toFixed(0);
        if (currentOrder == 0 || newOrder < currentOrder) {
          $(f).closest('.offers-table-row').css('order', newOrder);
        }
      });
    }
  });

  let sorted = $('#offers_table').children().sort(function (a, b) {
    return parseInt($(a).css('order')) - parseInt($(b).css('order'));
  });

  $('#offers_table').html(sorted);

  $('.offers-merchant').width('140px');
  $('.fees').width('110px');
}