Убираем забронированные товары из поиска авито и добавляем фильтр только по точным совпадениям
Скрипты для консоли:
Для того чтобы убрать забронированные товары из выдаваемого списка объявлений просто откройте консоль разработчика на f12 -> Console
-> и вставьте
// ==UserScript==
// @name Avito — скрыть забронированные
// @namespace avito-hide-reserved
// @VERSION 1.0
// @Description Скрывает забронированные товары на Авито
// @match https://www.avito.ru/*
// @match https://avito.ru/*
// @GrAnt none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
let enabled = localStorage.getItem(
'avito-hide-reserved'
) !== 'false';
const reserved = /^(забронирован[оа]?|в резерве|в брони|товар забронирован|объявление забронировано)$/i;
const cardSelector = '[data-marker="item"]';
const hiddenClass = 'avito-reserved-hidden';
const style = document.createElement('style');
style.textContent = `
.${hiddenClass} {
display: none !important;
}
`;
document.head.appendChild(style);
const button = document.createElement('button');
Object.assign(button.style, {
position: 'fixed',
bottom: '20px',
right: '20px',
zIndex: '999999',
padding: '12px 18px',
border: 'none',
borderRadius: '12px',
color: '#fff',
fontSize: '14px',
fontWeight: '600',
cursor: 'pointer',
boxShadow: '0 4px 15px #0003'
});
document.body.appendChild(button);
function filterItems() {
let count = 0;
document.querySelectorAll(cardSelector)
.forEach(card => {
const elements = [
card,
...card.querySelectorAll('*')
];
const isReserved = elements.some(el => {
const text = el.textContent
.replace(/\s+/g, ' ')
.trim();
return reserved.test(text);
});
const hide = enabled && isReserved;
card.classList.toggle(hiddenClass, hide);
if (hide) count++;
});
const label = enabled
? `Скрыто: ${count} | ВКЛ`
: 'Фильтр брони: ВЫКЛ';
if (button.textContent !== label) {
button.textContent = label;
}
button.style.background = enabled
? '#16803c'
: '#555';
}
button.addEventListener('click', () => {
enabled = !enabled;
localStorage.setItem(
'avito-hide-reserved',
String(enabled)
);
filterItems();
});
let timer;
const observer = new MutationObserver(() => {
clearTimeout(timer);
timer = setTimeout(filterItems, 150);
});
observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true
});
filterItems();
})();
Жмем Enter - и убираем ненужные нам товары. В планах написать расширение для браузера - чтобы при обновлении не проделывать это еще раз
Отдельный скрипт для Tampermonkey ():
Установите Tampermonkey в Chrome. Откройте его панель управления → «Утилиты» → «Импорт из файла», выбери Avito-Filter.user.js и подтвердите установку. Затем откройте поиск на Авито и нажми значок Tampermonkey. В меню включи нужные фильтры
// ==UserScript==
// @name Avito Filter
// @namespace local.avito-filter
// @version 1.0.0
// @description Локальные фильтры объявлений Авито
// @match https://*.avito.ru/*
// @NoFrames
// @run-at document-idle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_addValueChangeListener
// @grant GM_addStyle
// ==/UserScript==
(() => {
const labels = { reserved: 'Скрывать забронированные', titleOnly: 'Все слова запроса в заголовке' };
const options = {};
const commands = [];
let menuState;
GM_addStyle('[data-avito-filter-tm-hidden] { display:none !important; }');
function updateMenu() {
const state = JSON.stringify([options, hidden]);
if (state === menuState) return;
menuState = state;
commands.splice(0).forEach(id => GM_unregisterMenuCommand(id));
for (const [key,label] of Object.entries(labels)) {
commands.push(GM_registerMenuCommand((options[key] ? '✓ ' : '○ ') + label, () => {
GM_setValue(key, !options[key]);
}));
}
commands.push(GM_registerMenuCommand('Скрыто на странице: ' + hidden, scan));
}
for (const key of Object.keys(labels)) {
options[key] = GM_getValue(key, false);
GM_addValueChangeListener(key, (_, oldValue, value) => {
options[key] = value === true;
schedule();
});
}
let timer;
let lastUrl;
let hidden = 0;
const cardSelector = '[data-marker="item"], [data-item-id]';
const flag = 'data-avito-filter-tm-hidden';
const normalize = value => value.toLocaleLowerCase('ru').replace(/ё/g, 'е');
const words = value => normalize(value).match(/[\p{L}\p{N}]+/gu) || [];
function isReserved(card) {
const status = /^(?:забронирован[аоы]?|в брони|под бронью|в резерве|зарезервирован[аоы]?)$/iu;
const labels = card.querySelectorAll('span, div, p, small, [aria-label], [title]');
return Array.from(labels).some(el => {
if (el.closest('[data-marker*="description"], [data-marker="item-title"], h2, h3')) return false;
const candidates = [el.getAttribute('aria-label'), el.getAttribute('title')];
if (!el.childElementCount) candidates.push(el.textContent);
return candidates.some(value => value && status.test(value.trim()));
});
}
function scan() {
clearTimeout(timer);
timer = undefined;
lastUrl = location.href;
const query = words(new URL(lastUrl).searchParams.get('q') || '');
hidden = 0;
for (const card of document.querySelectorAll(cardSelector + ', [' + flag + ']')) {
const current = card.matches(cardSelector) && !card.parentElement?.closest(cardSelector);
const titleEl = current && card.querySelector('[data-marker="item-title"]');
const heading = titleEl || (current && card.querySelector('h2, h3'));
const title = heading && (heading.textContent.trim() || heading.getAttribute('title'));
const titleWords = options.titleOnly && query.length && title ? new Set(words(title)) : null;
const hide = Boolean(current && ((titleWords && query.some(w => !titleWords.has(w))) ||
(options.reserved && isReserved(card))));
card.toggleAttribute(flag, hide);
if (hide) hidden++;
}
updateMenu();
}
function schedule() {
if (timer === undefined) timer = setTimeout(scan, 100);
}
new MutationObserver(schedule).observe(document.documentElement, {
subtree: true, childList: true, characterData: true, attributes: true,
attributeFilter: ['data-marker', 'data-item-id', 'title', 'aria-label']
});
setInterval(() => { if (location.href !== lastUrl) schedule(); }, 600);
scan();
})();

