Reddit bug workaround to allow posting on the r/userscript subreddit.

Redirects Reddit's submit page for r/userscripts to the old Reddit interface to fix the bug accessing the new interfaces's submit page for the subreddit.

  1. // ==UserScript==
  2. // @name Reddit bug workaround to allow posting on the r/userscript subreddit.
  3. // @namespace https://gist.github.com/f-steff
  4. // @version 1.2
  5. // @description Redirects Reddit's submit page for r/userscripts to the old Reddit interface to fix the bug accessing the new interfaces's submit page for the subreddit.
  6. // @author Flemming Steffensen
  7. // @license MIT
  8. // @match https://www.reddit.com/r/userscripts/*
  9. // @match https://old.reddit.com/r/*/comments/*
  10. // @grant none
  11. // @homepageURL https://gist.github.com/f-steff/cd4c5fafc574e5595fc7a153516792ab
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // Redirect old.reddit.com comment links to www.reddit.com
  20. if (window.location.href.includes('old.reddit.com') && window.location.href.includes('/comments/')) {
  21. window.location.href = window.location.href.replace('old.reddit.com', 'www.reddit.com');
  22. }
  23.  
  24. // Function to modify the "Create Post" button
  25. function modifyCreatePostButton() {
  26. const createPostButton = document.querySelector('a[data-testid="create-post"]');
  27. if (createPostButton && createPostButton.href.includes('www.reddit.com')) {
  28. createPostButton.href = createPostButton.href.replace('www.reddit.com', 'old.reddit.com');
  29. }
  30. }
  31.  
  32. // Ensure the DOM is fully loaded before running
  33. function init() {
  34. modifyCreatePostButton();
  35.  
  36. // Observe for dynamic changes to the page and reapply the modification if needed
  37. const observer = new MutationObserver(() => {
  38. modifyCreatePostButton();
  39. });
  40.  
  41. observer.observe(document.body, { childList: true, subtree: true });
  42. }
  43.  
  44. if (window.location.href.includes('/r/userscripts/')) {
  45. if (document.readyState === 'loading') {
  46. document.addEventListener('DOMContentLoaded', init);
  47. } else {
  48. init();
  49. }
  50. }
  51. })();

QingJ © 2025

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