Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orbitrod/d7e3e319d350ae990e31ea747701bd5a to your computer and use it in GitHub Desktop.
Save orbitrod/d7e3e319d350ae990e31ea747701bd5a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name eBay Hide Zero Quantity Items (Bulk Sell)
// @namespace https://www.ebay.com
// @version 1.0
// @description Hide rows of items with zero quantity on eBay bulk sell page and add a button to show them.
// @author Forzza Services
// @match https://www.ebay.com/bulksell*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addShowZeroQuantityButton() {
const buttonContainer = document.querySelector('.app-summary__left');
if (!buttonContainer) return; // Exit if the container doesn't exist
const showButton = document.createElement('button');
showButton.innerHTML = 'Hide Zero Quantity Items';
showButton.className = 'btn btn--small btn--secondary';
showButton.style.backgroundColor = '#ffc107';
showButton.style.color = '#000000';
let showZeroQuantity = true;
function toggleShowZeroQuantity() {
const rows = document.querySelectorAll('.bg-grid__row');
if (showZeroQuantity) {
rows.forEach((row) => {
const quantityInput = row.querySelector('input[aria-labelledby="quantity"][value="0"]');
if (quantityInput) {
row.style.display = 'none';
}
});
showButton.innerHTML = 'Show Zero Quantity Items';
} else {
rows.forEach((row) => {
row.style.display = '';
});
showButton.innerHTML = 'Hide Zero Quantity Items';
}
showZeroQuantity = !showZeroQuantity;
// Count the number of visible items
const visibleItems = Array.from(rows).filter((row) => row.style.display !== 'none');
countLabel.innerHTML = `Items shown: ${visibleItems.length}`;
}
showButton.addEventListener('click', toggleShowZeroQuantity);
const countLabel = document.createElement('span');
countLabel.id = 'show-zero-quantity-count';
countLabel.style.marginLeft = '5px';
countLabel.style.fontSize = '12px';
countLabel.style.color = '#000000';
const container = document.createElement('div');
container.style.display = 'flex';
container.style.alignItems = 'center';
container.appendChild(showButton);
container.appendChild(countLabel);
buttonContainer.appendChild(container);
}
// Ensure all elements are fully loaded
setTimeout(() => {
addShowZeroQuantityButton();
}, 2000); // wait for 2 seconds
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment