Greasy Fork is available in English.

Scrolller.com Redirector

Redirect Scrolller subreddit pages to sorted and filtered view

  1. // ==UserScript==
  2. // @name Scrolller.com Redirector
  3. // @namespace http://tampermonkey.net/
  4. // @license MIT
  5. // @version 0.1
  6. // @description Redirect Scrolller subreddit pages to sorted and filtered view
  7. // @icon https://scrolller.com/assets/favicon-16x16.png
  8. // @author nkatshiba
  9. // @match https://scrolller.com/r/*
  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 = new URL(window.location.href);
  19.  
  20. // Check if the URL already contains the desired parameters
  21. var params = currentUrl.searchParams;
  22.  
  23. // Only add the parameters if they are not already set correctly
  24. var needsRedirect = false;
  25. if (params.get('sort') !== 'rising') {
  26. params.set('sort', 'rising');
  27. needsRedirect = true;
  28. }
  29. if (params.get('filter') !== 'videos') {
  30. params.set('filter', 'videos');
  31. needsRedirect = true;
  32. }
  33.  
  34. // Construct the new URL if needed
  35. if (needsRedirect) {
  36. var newUrl = currentUrl.origin + currentUrl.pathname + '?' + params.toString();
  37. window.location.replace(newUrl);
  38. }
  39. })();