Marktplaats clickable user profile url in bids

make marktplaats bid username clickable

  1. // ==UserScript==
  2. // @name Marktplaats clickable user profile url in bids
  3. // @namespace https://greasyfork.org/en/users/1251054-djoey
  4. // @version 0.3
  5. // @description make marktplaats bid username clickable
  6. // @author JustDjoey
  7. // @match https://www.marktplaats.nl/v/*/*/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=marktplaats.nl
  9. // @grant none
  10. // @run-at document-idle
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var bids = window.__CONFIG__.listing.bidsInfo.bids;
  18.  
  19. function createClickableLinks() {
  20. let bids_html = document.getElementsByClassName("BiddingList-content");
  21. Array.from(bids_html).forEach(function(element) {
  22. let price = element.getElementsByClassName('BiddingList-price')[0].innerText.replace(/\D/g, "");
  23. let username = element.children[0].textContent;
  24. let bid_info = bids.find(x => (x.value == price && x.user.nickname == username));
  25. let user = bid_info.user;
  26.  
  27. element.children[0].innerHTML = '<a target="_blank" href="https://www.marktplaats.nl/u/' + user.nickname + '/' + user.id + '" >' + user.nickname + '</a>';
  28. });
  29. }
  30.  
  31. function recheck() {
  32. setTimeout(createClickableLinks,250)
  33. }
  34.  
  35. window.addEventListener('load', function() {
  36. createClickableLinks();
  37.  
  38. if(document.getElementsByClassName('BiddingList-showMore')[0]) {
  39. document.getElementsByClassName('BiddingList-showMore')[0].children[0].addEventListener("click", recheck);
  40. }
  41. });
  42.  
  43. })();