Greasy Fork is available in English.

Params Class

URL params utility class

Tento skript by nemal byť nainštalovaný priamo. Je to knižnica pre ďalšie skripty, ktorú by mali používať cez meta príkaz // @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);
  }
}