Reddit to Libreddit Redirect

Redirects Reddit links to Libreddit links automatically.

目前为 2023-06-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit to Libreddit Redirect
  3. // @namespace https://kbin.social/u/LollerCorleone
  4. // @version 1.0
  5. // @description Redirects Reddit links to Libreddit links automatically.
  6. // @author LollerCorleone
  7. // @license GNU GPLv3
  8. // @match *://www.reddit.com/*
  9. // @match *://old.reddit.com/*
  10. // @grant none
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Get the current URL
  18. var currentUrl = window.location.href;
  19.  
  20. // Check if the URL matches the Reddit homepage
  21. if (currentUrl === 'https://www.reddit.com/' || currentUrl === 'https://old.reddit.com/') {
  22. // Redirect to the Libreddit homepage
  23. window.location.replace('https://libreddit.privacy.com.de/');
  24. return; // Stop further script execution
  25. } else if (currentUrl.match(/https?:\/\/(?:www|old)\.reddit\.com\/r\/\w+\//)) {
  26. // Construct the Libreddit subreddit URL
  27. var libredditUrl = currentUrl.replace(/https?:\/\/(?:www|old)\.reddit\.com/, 'https://libreddit.privacy.com.de');
  28. // Redirect to the Libreddit subreddit URL
  29. window.location.replace(libredditUrl);
  30. return; // Stop further script execution
  31. } else if (currentUrl.match(/https?:\/\/(?:www|old)\.reddit\.com\/r\/\w+\/comments\/\w+\//)) {
  32. // Construct the Libreddit post URL
  33. var libredditUrl = currentUrl.replace(/https?:\/\/(?:www|old)\.reddit\.com/, 'https://libreddit.privacy.com.de');
  34. // Redirect to the Libreddit post URL
  35. window.location.replace(libredditUrl);
  36. return; // Stop further script execution
  37. }
  38. })();

QingJ © 2025

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