Archive for April, 2026
Stopping Pinterest page auto-refresh
For anyone using Instagram, Pinterest or similar social media sites, they will often auto-refresh their page to increase ads, impressions and engagement, which is annoying if you’re trying to read content, search a product or just maintain your context.
Open a new browser tab, do a search, close the tab, and your already-open Pinterest tab refreshes on you, losing your position where you were just moments before.
This is most apparent when you’re reading on a mobile device, lock your phone, and then unlock it a minute later. The page reloads, refreshes and you lose where you were just a minute prior. There’s no way to get back, because there’s no “view history” of those moments.
So I decided to “fix the glitch” with a browser userscript, using ViolentMonkey in my case on Brave, Chrome and Firefox.
This specifically tries 5 different methods of auto-refresh, not just scraping page content and injecting or redacting CSS classes. It’s been working flawlessly for me for about a week.
// ==UserScript==
// @name Pinterest - Disable Auto Refresh
// @namespace https://tampermonkey.net/
// @version 2026.04.18
// @author setuid@gmail.com
// @description Tries to stop Pinterest from auto-refreshing or force-reloading pages
// @match https://www.pinterest.com/*
// @run-at document-start
// @grant unsafeWindow
// ==/UserScript==
(function () {
'use strict';
const w = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
const log = (...args) => console.log('[TM no-refresh]', ...args);
const killMetaRefresh = () => {
for (const meta of document.querySelectorAll('meta[http-equiv]')) {
if ((meta.getAttribute('http-equiv') || '').toLowerCase() === 'refresh') {
meta.remove();
log('Removed meta refresh tag');
}
}
};
const originalReload = w.location.reload.bind(w.location);
w.location.reload = function () {
log('Blocked location.reload()');
};
const originalAssign = w.location.assign.bind(w.location);
const originalReplace = w.location.replace.bind(w.location);
w.location.assign = function (url) {
if (!url || String(url) === w.location.href) {
log('Blocked location.assign() to same URL');
return;
}
return originalAssign(url);
};
w.location.replace = function (url) {
if (!url || String(url) === w.location.href) {
log('Blocked location.replace() to same URL');
return;
}
return originalReplace(url);
};
const origGo = history.go.bind(history);
history.go = function (delta) {
if (delta === 0) {
log('Blocked history.go(0)');
return;
}
return origGo(delta);
};
const origSetTimeout = w.setTimeout.bind(w);
const origSetInterval = w.setInterval.bind(w);
const looksLikeRefreshCode = (fn) => {
const s = String(fn);
return /reload\s*\(|location\.href|location\.assign|location\.replace|history\.go\s*\(\s*0\s*\)/i.test(s);
};
w.setTimeout = function (fn, delay, ...args) {
if (typeof fn === 'function' && looksLikeRefreshCode(fn)) {
log('Blocked setTimeout refresh callback');
return 0;
}
if (typeof fn === 'string' && looksLikeRefreshCode(fn)) {
log('Blocked setTimeout refresh string');
return 0;
}
return origSetTimeout(fn, delay, ...args);
};
w.setInterval = function (fn, delay, ...args) {
if (typeof fn === 'function' && looksLikeRefreshCode(fn)) {
log('Blocked setInterval refresh callback');
return 0;
}
if (typeof fn === 'string' && looksLikeRefreshCode(fn)) {
log('Blocked setInterval refresh string');
return 0;
}
return origSetInterval(fn, delay, ...args);
};
const mo = new MutationObserver(() => killMetaRefresh());
mo.observe(document.documentElement, { childList: true, subtree: true });
killMetaRefresh();
log('No-refresh hooks installed');
})();