Enhance Your Reddit Browsing Experience: Skip Image Preview Pages. Introducing a UserScript to Load Images Directly in New Tabs!
With this lightweight UserScript, you can bypass those annoying pop-ups and load images directly in new tabs with a simple right-click. Enjoy a seamless browsing experience and spend less time waiting for images to load. Install now and enhance your Reddit experience!
Inspired from (full credits to makers. I just didn’t want another extension so translated it to UserScript):
- GitHub - MonsterMannen/reddit-load-images-directly-chrome: Chrome extension to bypass reddits annoying page when opening images in a new tab
- GitHub - nopperl/load-reddit-images-directly: Firefox web extension that loads reddit images directly instead of referring to the HTML page containing the image.
Script:
// ==UserScript==
// @name Reddit Image Direct Load
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Bypass Reddit image preview pages and load images directly in new tabs
// @author Your name
// @match *://www.reddit.com/media*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
'use strict';
// Define rules to modify headers
const rules = [
{
urlFilter: '*://external-preview.redd.it/*',
headers: { 'Accept': 'image/avif,image/webp,*/*' }
},
{
urlFilter: '*://i.redd.it/*',
headers: { 'Accept': 'image/avif,image/webp,*/*' }
},
{
urlFilter: '*://preview.redd.it/*',
headers: { 'Accept': 'image/avif,image/webp,*/*' }
},
{
urlFilter: '*://*.reddit.com/*',
headers: { 'Accept': 'image/avif,image/webp,*/*' }
}
];
// Add rules to modify headers
rules.forEach(rule => {
const { urlFilter, headers } = rule;
const pattern = new RegExp(urlFilter.replace(/\*/g, '.*'));
GM_xmlhttpRequest({
method: 'GET',
url: window.location.href,
onload: function(response) {
if (pattern.test(response.finalUrl)) {
Object.keys(headers).forEach(header => {
GM_xmlhttpRequest({
method: 'HEAD',
url: response.finalUrl,
headers: {
[header]: headers[header]
}
});
});
}
}
});
});
})();
Add this script to TamperMonkey (or any other UserScript extension). Safari has “Userscripts” extension.
-
Install Tampermonkey: Get the Tampermonkey extension for your browser.
-
Copy the Script: Copy the provided UserScript code.
-
Add New Script: Open Tampermonkey, go to the Dashboard, and click the “Plus” icon to add a new script.
-
Paste the Code: Paste the copied code into the script editor.
-
Save and Enable: Save the script and make sure it’s enabled in Tampermonkey.
That’s it! The script will now run whenever you browse Reddit, bypassing image preview pages. Enjoy!