Skip to content

Instantly share code, notes, and snippets.

@qFamouse
Last active November 28, 2025 21:14
Show Gist options
  • Select an option

  • Save qFamouse/e5356f5cb58a27b25606a5283285d941 to your computer and use it in GitHub Desktop.

Select an option

Save qFamouse/e5356f5cb58a27b25606a5283285d941 to your computer and use it in GitHub Desktop.
Добавляет полезные кнопки на страницу сравнения Onliner. Удаление границ ширины (для широких мониторов удобнее сравнивать), добавить подписи Есть/Нету (использую для передачи информации нейросетям)
// ==UserScript==
// @name Compare Helper
// @namespace https://github.com/qFamouse/
// @version 1.3
// @description Добавляет полезные кнопки на страницу сравнения Onliner
// @author Famouse
// @match https://catalog.onliner.by/compare/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=onliner.by
// @grant none
// @updateURL https://gist.github.com/qFamouse/e5356f5cb58a27b25606a5283285d941/raw/fe84a066780a09e9248a283521a7eaac430eed5f/onliner-compare-helper.user.js
// @downloadURL https://gist.github.com/qFamouse/e5356f5cb58a27b25606a5283285d941/raw/fe84a066780a09e9248a283521a7eaac430eed5f/onliner-compare-helper.user.js
// ==/UserScript==
(function() {
'use strict';
function addButtons() {
const container = document.querySelector('.product-table__cell.product-table__cell_small');
if (!container || container.querySelector('.custom-compare-button')) {
return;
}
// Кнопка удаления границ
const removeBordersButton = document.createElement('a');
removeBordersButton.textContent = 'Убрать границы';
removeBordersButton.className = 'product-table__clear button button_gray button_small custom-compare-button';
removeBordersButton.href = '#';
removeBordersButton.style.cssText = 'margin-left: 8px; pointer-events: auto;';
removeBordersButton.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
const middleElement = document.querySelector(".g-middle-i");
const tableContainer = document.querySelector(".product-table-container");
if (middleElement) middleElement.style.maxWidth = "none";
if (tableContainer) tableContainer.style.maxWidth = "none";
}, true);
// Кнопка добавления текста
const addExistsTextButton = document.createElement('a');
addExistsTextButton.textContent = 'Добавить есть/нету';
addExistsTextButton.className = 'product-table__clear button button_gray button_small custom-compare-button';
addExistsTextButton.href = '#';
addExistsTextButton.style.cssText = 'margin-left: 8px; pointer-events: auto;';
addExistsTextButton.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
document.querySelectorAll('.product-icon.product-icon_tip').forEach(x => x.textContent = "Есть. ");
document.querySelectorAll('.product-icon.product-icon_x').forEach(x => x.textContent = "Нету. ");
}, true);
container.appendChild(removeBordersButton);
container.appendChild(addExistsTextButton);
}
// Первоначальная попытка добавить кнопки
let attempts = 0;
const interval = setInterval(() => {
attempts++;
if (addButtons() || attempts >= 50) {
clearInterval(interval);
}
}, 200);
// Отслеживаем изменения DOM и восстанавливаем кнопки при необходимости
const observer = new MutationObserver(() => {
if (!document.querySelector('.custom-compare-button')) {
addButtons();
}
});
if (document.body) {
observer.observe(document.body, {
childList: true,
subtree: true
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment