Kijiji: Hide Non-Local Listings

Removes ads with only "Canada" or provence name listed as location

  1. // ==UserScript==
  2. // @name Kijiji: Hide Non-Local Listings
  3. // @description Removes ads with only "Canada" or provence name listed as location
  4. // @match https://www.kijiji.ca/b*
  5. // @version 0.1
  6. // @author mica
  7. // @namespace greasyfork.org/users/12559
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. const list = [
  12. 'Canada',
  13. 'Alberta',
  14. 'British Columbia',
  15. 'Manitoba',
  16. 'New Brunswick',
  17. 'Newfoundland',
  18. 'Northwest Territories',
  19. 'Nova Scotia',
  20. 'Ontario',
  21. 'Prince Edward Island',
  22. 'Québec',
  23. 'Saskatchewan',
  24. 'Yukon'
  25. ];
  26.  
  27. const observer = new MutationObserver(() => {
  28. var elements = document.querySelectorAll('p[data-testid="listing-location"]')
  29. elements.forEach((element) => {
  30. if (list.includes(element.innerText)) {
  31. element.closest('li').style.display = 'none';
  32. }
  33. });
  34. });
  35.  
  36. observer.observe(document.body, {
  37. childList: true,
  38. subtree: true
  39. });