Greasy Fork is available in English.

Add Catawiki commission fees

This script allows to visualize the final price of the item adding fee commisions on Catawiki.

  1. // ==UserScript==
  2. // Creation Date: 31/8/2022, 14:45:43
  3. // @name Add Catawiki commission fees
  4. // @name:it Aggiungi commisioni d'asta Catawiki
  5. // @namespace https://nicksenzaname.github.io/
  6. // @description This script allows to visualize the final price of the item adding fee commisions on Catawiki.
  7. // @description:it Questo script permette di visualizzare il prezzo finale di un oggetto aggiungendovi le commisioni d'asta su Catawiki.
  8. // @match https://www.catawiki.com/*
  9. // @grant none
  10. // @homepageURL https://greasyfork.org/it/scripts/450544-add-catawiki-commission-fees
  11. // @version 1.0.1
  12. // @author NickSenzaName
  13. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  14. // ==/UserScript==
  15.  
  16. // --- Function Declaration ---
  17. function hasNumber(str) {
  18. let regex = /\d/;
  19. return regex.test(str);
  20. }
  21.  
  22. function str_to_nr(str) {
  23. let splitted_str = str.split(' ');
  24. let i = 0;
  25. while (!hasNumber(splitted_str[i])) {
  26. i++;
  27. }
  28. return parseFloat(str.split(' ')[i]);
  29. }
  30.  
  31. function add_percentage(number, percentage) {
  32. return number + number*percentage;
  33. }
  34.  
  35. function set_new_price_label(element) {
  36. let bid = str_to_nr(element.innerHTML);
  37. bid = add_percentage(bid, 0.09);
  38. element.innerHTML = element.innerHTML + '<br>(' + bid.toString() + ' €)';
  39. // console.log(element.innerHTML);
  40. }
  41.  
  42. // --- Main ---
  43.  
  44. setTimeout(function(){
  45. if (typeof elements === 'undefined') {
  46. let elements;
  47. }
  48. elements = document.getElementsByClassName('c-button__label');
  49.  
  50. for (let i = 0; i < elements.length; i++) {
  51. if (elements[i].innerHTML.includes("€")) {
  52. set_new_price_label(elements[i]);
  53. }
  54. }
  55. }, 2000);