Scrolller.com Redirector

Redirect Scrolller subreddit pages to sorted and filtered view

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name          Scrolller.com Redirector
// @namespace     http://tampermonkey.net/
// @license       MIT
// @version       0.1
// @description   Redirect Scrolller subreddit pages to sorted and filtered view
// @icon          https://scrolller.com/assets/favicon-16x16.png
// @author        nkatshiba
// @match         https://scrolller.com/r/*
// @grant         none
// @run-at        document-start
// ==/UserScript==

(function() {
    'use strict';

    // Get the current URL
    var currentUrl = new URL(window.location.href);

    // Check if the URL already contains the desired parameters
    var params = currentUrl.searchParams;

    // Only add the parameters if they are not already set correctly
    var needsRedirect = false;
    if (params.get('sort') !== 'rising') {
        params.set('sort', 'rising');
        needsRedirect = true;
    }
    if (params.get('filter') !== 'videos') {
        params.set('filter', 'videos');
        needsRedirect = true;
    }

    // Construct the new URL if needed
    if (needsRedirect) {
        var newUrl = currentUrl.origin + currentUrl.pathname + '?' + params.toString();
        window.location.replace(newUrl);
    }
})();