Greasy Fork is available in English.

Params Class

URL params utility class

Ce script ne devrait pas être installé directement. C'est une librairie créée pour d'autres scripts. Elle doit être inclus avec la commande // @require https://update.greasyfork.org/scripts/476650/1259545/Params%20Class.js

// ==UserScript==
// @name         Params Class
// @version      1.0.0
// @description  URL params utility class
// @author       Paweł Malak (pawemala) LCJ2
// @license      MIT
// ==/UserScript==

class Params {
  /**
   * Check if parameter exists in the URL search parameters
   * @param {string} key name of sought parameter
   * @returns {string | null} value of parameter if it exists, or null if it doesn't
   */
  static getParameter(key) {
    const searchParams = new URLSearchParams(window.location.search);

    if (!searchParams.has(key)) {
      return null;
    }

    return searchParams.get(key);
  }
}