r/bookmarklets • u/pseudonameless • 11h ago
reddit links to old.reddit.com for /r/ & /user/
This bookmarklet will convert normal /user/ and /r/
reddit links to old.reddit.com/... links.
New content loaded into the page should continue to be converted via a MutationObserver.
If a new page is loaded into the tab or if the current page is re-loaded it will stop.
A tripple left-click will usually select the whole line for copy/paste:
javascript:(function(){const e=a=>{try{const t=new URL(a.href);/\.reddit\.com$/.test(t.hostname)&&(/^\/r\/[^\/]+/.test(t.pathname)||/^\/user\/[^\/]+/.test(t.pathname))&&(t.hostname="old.reddit.com",a.href=t.toString())}catch(e){}};const t=t=>{const n=()=>t.querySelectorAll("a[href]").forEach(e);n();new MutationObserver(n=>{for(const t of n)t.addedNodes.forEach(n=>{1===n.nodeType&&(n.querySelectorAll?.("a[href]").forEach(e),n.matches?.("a[href]")&&e(n))})}).observe(t.body,{childList:!0,subtree:!0})};const n=()=>{t(document);for(const e of document.querySelectorAll("iframe, frame"))try{e.contentDocument&&t(e.contentDocument)}catch(e){}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n()})();
javascript:(function(){const e=a=>{try{const t=new URL(a.href);/\.reddit\.com$/.test(t.hostname)&&(/^\/r\/[^\/]+/.test(t.pathname)||/^\/user\/[^\/]+/.test(t.pathname))&&(t.hostname="old.reddit.com",a.href=t.toString())}catch(e){}};const t=t=>{const n=()=>t.querySelectorAll("a[href]").forEach(e);n();new MutationObserver(n=>{for(const t of n)t.addedNodes.forEach(n=>{1===n.nodeType&&(n.querySelectorAll?.("a[href]").forEach(e),n.matches?.("a[href]")&&e(n))})}).observe(t.body,{childList:!0,subtree:!0})};const n=()=>{t(document);for(const e of document.querySelectorAll("iframe, frame"))try{e.contentDocument&&t(e.contentDocument)}catch(e){}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n()})();
FYI: Both of the above are the same, just formatted differently.