Greasy Fork is available in English.

Params Class

URL params utility class

Acest script nu ar trebui instalat direct. Aceasta este o bibliotecă pentru alte scripturi care este inclusă prin directiva meta a // @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);
  }
}