CursedForge

Keep CurseForge's "Game Version" filter when searching

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         CursedForge
// @namespace    Fourmisain
// @version      0.1.1
// @description  Keep CurseForge's "Game Version" filter when searching
// @author       Fourmisain
// @match        https://www.curseforge.com/*
// @license      CC0-1.0; https://creativecommons.org/publicdomain/zero/1.0/legalcode
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  // "Game Version", which for Minecraft can also be Fabric or Forge
  const filter = new URL(document.location).searchParams.get('filter-game-version');
  if (!filter) return;

  function addFormFilter(form) {
    // add hidden input which adds the current "Game Version" filter
    const input = document.createElement('INPUT');
    input.name = 'filter-game-version';
    input.value = filter;
    input.type = 'hidden';
    // may not be needed:
    input.class = 'valid';
    input.ariaInvalid = 'false';

    form.appendChild(input);
  }

  // find search form on search page
  const searchForms = document.getElementsByClassName('search-form');
  if (searchForms.length === 1) {
    addFormFilter(searchForms[0]);
    return;
  }

  // find search form on main mods page
  for (const form of document.getElementsByTagName('form')) {
    if (form.classList.contains('h-full')) {
      addFormFilter(form);
      return;
    }
  }

})();