Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CezaryDanielNowak/6c0cc78480adb810b0eb3593d5c4f03f to your computer and use it in GitHub Desktop.
Save CezaryDanielNowak/6c0cc78480adb810b0eb3593d5c4f03f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Allegro filtruj po cenie przeliczeniowej
// @namespace http://tampermonkey.net/
// @version 2025-06-03
// @author https://github.com/cezarydanielnowak
// @match https://allegro.pl/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=allegro.pl
// @grant none
// ==/UserScript==
/*
UWAGA:
Allegro blokuje greasemonkey/tampermonkey.
Wklej kod w konsoli i będzie działało.
*/
(function() {
'use strict';
const btn = Object.assign(document.createElement('button'), {
onclick: () => {
const cenaPrzeliczeniowa = 1 * prompt('Cena przeliczeniowa mniejsza lub równa:', 1).replace(',', '.');
const rawResults = document.evaluate("//*[contains(., 'zł/szt')]", document, null, XPathResult.ANY_TYPE, null);
const goodResults = [];
while (true) {
const next = rawResults.iterateNext();
if (!next) {
break;
}
if (
next.childNodes.length === 1 &&
next.childNodes[0].nodeType === 3 &&
parseFloat(next.innerText.replace('szt.', '').replace(',', '.').replace(',', '.').replace(/[^.0-9]/g, '')) <= cenaPrzeliczeniowa
) {
goodResults.push(next);
}
}
[...document.querySelectorAll('.opbox-listing article')].forEach((el) => {
if (!goodResults.some((goodResult) => el.contains(goodResult))) {
el.style.display = 'none';
}
});
}
})
document.body.appendChild(btn);
btn.click();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment