Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Reddit Image Direct Link
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Open Reddit images directly
- // @author You
- // @match https://www.reddit.com/*
- // @match https://old.reddit.com/*
- // @match https://preview.redd.it/*
- // @match https://i.redd.it/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var xhrOverride = function(xhr) {
- xhr.setRequestHeader('Accept', 'image/*');
- };
- var openOverride = function(open) {
- return function(url, method, async, user, password) {
- if (url.startsWith('https://preview.redd.it/') || url.startsWith('https://i.redd.it/')) {
- xhrOverride(this);
- }
- return open.apply(this, arguments);
- };
- };
- XMLHttpRequest.prototype.open = openOverride(XMLHttpRequest.prototype.open);
- })();
Advertisement
Add Comment
Please, Sign In to add comment