It hides all promoted ads on OLX
// ==UserScript==
// @name Hide OLX Promoted Ads
// @name:ro Ascunde Anunțuri De Tip PROMOVAT Pe OLX
// @name:bg Скриване На Реклами Тип ПРОМОТИРАНА ОБЯВА На OLX
// @name:ua Приховати Оголошення Типу ТОП На OLX
// @name:pt Ocultar Anúncios Do Tipo TOP No OLX
// @name:pl Ukryj Ogłoszenia Typu WYRÓŻNIONE Na OLX
// @description It hides all promoted ads on OLX
// @description:ro Ascunde toate anunțurile de tip PROMOVAT de pe OLX
// @description:bg Скрива всички реклами тип ПРОМОТИРАНА ОБЯВА на OLX
// @description:ua Сховує всі оголошення типу ТОП на OLX
// @description:pt Oculta todos os anúncios do tipo TOP no OLX
// @description:pl Ukrywa wszystkie ogłoszenia typu WYRÓŻNIONE na OLX
// @author NWP
// @namespace https://greasyfork.org/users/877912
// @version 0.3
// @license MIT
// @match *://www.olx.ro/*
// @match *://www.olx.bg/*
// @match *://www.olx.ua/*
// @match *://www.olx.pt/*
// @match *://www.olx.pl/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const DEBUG = false;
const PROMO_LABELS = {
'olx.ro': ['PROMOVAT'],
'olx.bg': ['ПРОМОТИРАНА ОБЯВА'],
'olx.ua': ['ТОП'],
'olx.pt': ['TOP'],
'olx.pl': ['WYRÓŻNIONE']
};
const hostKey = window.location.hostname.replace(/^www\./, '');
const keywords = PROMO_LABELS[hostKey] || Object.values(PROMO_LABELS).flat();
let totalHidden = 0;
let lastHideTime = Date.now();
function hidePromotedElements() {
const now = Date.now();
if (DEBUG) console.log(`[DEBUG ${new Date().toISOString()}] hidePromotedElements() called`);
const beforeCount = totalHidden;
document.querySelectorAll('[data-cy="l-card"]').forEach(card => {
const badge = card.querySelector('div.css-144z9p2');
if (!badge) return;
const label = badge.textContent.trim().toUpperCase();
if (keywords.includes(label) && card.style.display !== 'none') {
card.style.display = 'none';
totalHidden++;
if (DEBUG) {
const id = card.id || card.getAttribute('data-id') || '(no-id)';
console.log(
`[DEBUG ${new Date().toISOString()}] ➔ Hiding card ${id} (“${label}”). Total hidden: ${totalHidden}`
);
}
}
});
if (DEBUG && totalHidden > beforeCount) {
const delta = now - lastHideTime;
console.log(
`[DEBUG ${new Date().toISOString()}] hid ${totalHidden - beforeCount}` +
` new card(s) — cumulative ${totalHidden}` +
` (Δ ${delta} ms since last hide)`
);
lastHideTime = now;
}
}
if (DEBUG) console.log(`[DEBUG ${new Date().toISOString()}] Initial hide run`);
hidePromotedElements();
new MutationObserver(hidePromotedElements)
.observe(document.body, { childList: true, subtree: true });
setInterval(hidePromotedElements, 2000);
})();