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.

目前為 2025-01-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Reddit bug workaround to allow posting on the r/userscript subreddit.
// @namespace    https://gist.github.com/f-steff
// @version      1.1
// @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.
// @author       Flemming Steffensen
// @license      MIT
// @match        https://www.reddit.com/r/userscripts/*
// @grant        none
// @homepageURL  https://gist.github.com/f-steff/cd4c5fafc574e5595fc7a153516792ab
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // Function to modify the "Create Post" button
    function modifyCreatePostButton() {
        const createPostButton = document.querySelector('a[data-testid="create-post"]');
        if (createPostButton && createPostButton.href.includes('www.reddit.com')) {
            createPostButton.href = createPostButton.href.replace('www.reddit.com', 'old.reddit.com');
         }
    }

    // Ensure the DOM is fully loaded before running
    function init() {
        modifyCreatePostButton();

        // Observe for dynamic changes to the page and reapply the modification if needed
        const observer = new MutationObserver(() => {
            modifyCreatePostButton();
        });

        observer.observe(document.body, { childList: true, subtree: true });
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();

QingJ © 2025

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