Highlight low and out-of-stock items
Reads the inventory column and marks low-stock products yellow and out-of-stock red so you can restock faster.
Code to copy
(function () {
var LOW = 5;
function scan() {
try {
var rows = document.querySelectorAll('.Polaris-IndexTable__TableRow, table[class*="Polaris"] tbody tr');
rows.forEach(function (row) {
if (row.dataset.jzStock) return;
var t = (row.textContent || '').toLowerCase();
var out = /out of stock|0 in stock|unavailable/.test(t);
var low = false;
var lm = t.match(/(\d+)\s*in stock/);
if (lm && parseInt(lm[1], 10) <= LOW) low = true;
if (out) {
row.style.boxShadow = 'inset 4px 0 0 #c4341e';
row.style.background = 'rgba(196,52,30,0.12)';
} else if (low) {
row.style.boxShadow = 'inset 4px 0 0 #b98900';
row.style.background = 'rgba(255,196,0,0.14)';
}
row.dataset.jzStock = '1';
});
} catch (e) {}
}
scan();
new MutationObserver(scan).observe(document.body, { childList: true, subtree: true });
})();
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.