Skip to content

Instantly share code, notes, and snippets.

@jasonmadigan
Last active January 14, 2026 16:25
Show Gist options
  • Select an option

  • Save jasonmadigan/7bf4a27dcb141778fa54b416db07dac2 to your computer and use it in GitHub Desktop.

Select an option

Save jasonmadigan/7bf4a27dcb141778fa54b416db07dac2 to your computer and use it in GitHub Desktop.
TamperMonkey script - Screwfix.ie - in stock only toggle.
// ==UserScript==
// @name Screwfix.ie - In Stock Today Only (Any Store)
// @namespace http://tampermonkey.net/
// @version 3.1
// @description Filters catalog pages to show only items that can be collected today in your chosen store. Default store is New Ross, but you can change it in the script.
// @match https://www.screwfix.ie/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
// Change this to any Screwfix store name, e.g. "Cork", "Dublin - Ballymount"
const STORE = 'Waterford';
const STORAGE_KEY = 'sf-filter-stock-today';
// ---------------- UI ----------------
const box = document.createElement('div');
box.style.cssText = `
position: fixed;
bottom: 24px;
right: 24px;
z-index: 9999;
background: #fff;
border: 2px solid #005eb8;
border-radius: 8px;
padding: 10px 14px;
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
font-family: Arial, sans-serif;
display: flex;
align-items: center;
gap: 8px;
`;
const toggle = document.createElement('input');
toggle.type = 'checkbox';
toggle.id = 'sf-stock-toggle';
const label = document.createElement('label');
label.htmlFor = toggle.id;
label.textContent = 'In stock today only';
label.style.cursor = 'pointer';
label.style.fontWeight = '600';
box.appendChild(toggle);
box.appendChild(label);
document.body.appendChild(box);
// ---------------- Helpers ----------------
function getCards() {
return document.querySelectorAll('[data-qaid="product-card"]');
}
function getTile(card) {
return card.closest('.HfYajj') || card;
}
function isCollectToday(card) {
const stockEl = card.querySelector('[data-qaid="stock-info-message"]');
if (!stockEl) return false;
const text = stockEl.innerText.toLowerCase();
return text.includes(`collect today in ${STORE.toLowerCase()}`);
}
// ---------------- Filtering ----------------
function applyFilter() {
const cards = getCards();
cards.forEach(card => {
const tile = getTile(card);
tile.style.display = '';
});
if (!toggle.checked) return;
cards.forEach(card => {
if (!isCollectToday(card)) {
getTile(card).style.display = 'none';
}
});
}
// ---------------- State ----------------
function loadState() {
toggle.checked = localStorage.getItem(STORAGE_KEY) === 'true';
}
function saveState() {
localStorage.setItem(STORAGE_KEY, String(toggle.checked));
}
toggle.addEventListener('change', () => {
saveState();
applyFilter();
});
// ---------------- Navigation handling ----------------
let lastURL = location.href;
const observer = new MutationObserver(() => {
if (location.href !== lastURL) {
lastURL = location.href;
setTimeout(applyFilter, 600);
} else {
applyFilter();
}
});
observer.observe(document.body, { childList: true, subtree: true });
// ---------------- Init ----------------
loadState();
setTimeout(applyFilter, 800);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment