Guest User

Untitled

a guest
Aug 20th, 2024
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Reddit Image Direct Link
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Open Reddit images directly
  6. // @author You
  7. // @match https://www.reddit.com/*
  8. // @match https://old.reddit.com/*
  9. // @match https://preview.redd.it/*
  10. // @match https://i.redd.it/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var xhrOverride = function(xhr) {
  17. xhr.setRequestHeader('Accept', 'image/*');
  18. };
  19. var openOverride = function(open) {
  20. return function(url, method, async, user, password) {
  21. if (url.startsWith('https://preview.redd.it/') || url.startsWith('https://i.redd.it/')) {
  22. xhrOverride(this);
  23. }
  24. return open.apply(this, arguments);
  25. };
  26. };
  27. XMLHttpRequest.prototype.open = openOverride(XMLHttpRequest.prototype.open);
  28. })();
  29.  
Advertisement
Add Comment
Please, Sign In to add comment