Reddit Image Direcly (Farside)

This script uses the farside.link gateway to redirect images direcly on reddit

目前为 2025-01-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit Image Direcly (Farside)
  3. // @namespace https://gf.qytechs.cn/users/821661
  4. // @match https://www.reddit.com/media?url=*
  5. // @grant none
  6. // @version 1.0
  7. // @run-at document-start
  8. // @license GPL-3.0
  9. // @author hdyzen
  10. // @description This script uses the farside.link gateway to redirect images direcly on reddit
  11. // ==/UserScript==
  12.  
  13. // This script works thanks to farside.link gateway: https://github.com/benbusby/farside
  14. // Alternatively, you can use an extension to upload the image directly to Reddit:
  15. // Only for Firefox: https://addons.mozilla.org/pt-BR/firefox/addon/load-reddit-images-directly/
  16.  
  17. const getUrlObj = (url) => new URL(url);
  18.  
  19. const getImgUrl = (url) => {
  20. const nUrl = getUrlObj(url);
  21. const paramUrl = getUrlObj(nUrl.searchParams.get("url"));
  22. console.log(nUrl);
  23.  
  24. if (paramUrl.hostname === "external-preview.redd.it") {
  25. return `https://farside.link/libreddit/preview/external-pre${paramUrl.pathname + paramUrl.search}`;
  26. }
  27.  
  28. const fileName = paramUrl.pathname.match(/[^-\/]+\.(?:png|jpg|jpeg)$/)?.[0];
  29. return `https://farside.link/libreddit/img/${fileName}`;
  30. };
  31.  
  32. window.location.href = getImgUrl(window.location.href);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址