jQuery and common function shortcuts everywhere

injects jquery if not exists and adds some common function shortcuts to the window object. See al.help() for details.

Verze ze dne 29. 04. 2023. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         jQuery and common function shortcuts everywhere
// @namespace    https://github.com/Alistair1231/my-userscripts/
// @version      0.4.7
// @description  injects jquery if not exists and adds some common function shortcuts to the window object. See al.help() for details.
// @author       Alistair1231
// @match        *://*/*
// @grant        GM_xmlhttpRequest
// @license      GPL-3.0
// ==/UserScript==
// https://greasyfork.org/en/scripts/439017-jquery-and-common-function-shortcuts-everywhere
(function () {
  'use strict';
const helpString = `
'\
al: jQuery and Method shortcuts everywhere\\n\
------------------------------------------\\n\
al.cl(str) - console.log(str)\\n\
al.js(obj) - JSON.stringify(obj)\\n\
al.jsp(obj) - JSON.stringify(obj, null, 2)\\n\
al.jp(str) - JSON.parse(str)\\n\
al.qs(selector) - document.querySelector(selector)\\n\
al.qsa(selector) - document.querySelectorAll(selector)\\n\
al.gid(id) - document.getElementById(id)\\n\
al.print() - Prints the object definition\\n\
------------------------------------------\\n\
'
`;

const shortcuts = `
const al = {
  help: () => console.log(${helpString}),
  cl: (str) => console.log(str),
  js: (obj) => JSON.stringify(obj),
  jsp: (obj) => JSON.stringify(obj, null, 2),
  jp: (str) => JSON.parse(str),
  qs: (selector) => document.querySelector(selector),
  qsa: (selector) => document.querySelectorAll(selector),
  gid: (id) => document.getElementById(id),
  print: () => {
    const { help, ...rest } = al;
    console.log(rest);
  }
};
`;

  const e = document.createElement('script');
  e.id = 'injectedScript';
  e.innerText = shortcuts;
  


  
  document.head.appendChild(e);

})();