Greasy Fork is available in English.

H2P: utils

utils

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/411278/847435/H2P%3A%20utils.js

Autor
Greasy丶H2P
Version
0.1.1
Erstellt am
13.09.2020
Letzte Aktualisierung
13.09.2020
Lizenz
n/a

1. 引入脚本

根据 greasyFork 指引,到脚本开头 require 本脚本

2. 传入 $util

  (($util, $H2P) => {
    ...
  })($util, $H2P)

3. API

  // 键盘点击事件 code
  $util.keyCode.[a-z];

  // localStorage 操作
  $util.LS.init(itemKey = '', itemPre = {});
  $util.LS.set(itemKey = '', item = {});
  $util.LS.get(itemKey = '');
  $util.LS.remove(itemKey = '');

  // 根据毫秒获取 小时、分钟、秒
  // 返回 { h: '', m: '', s: '' },通过解耦获取
  $util.HMS(time = 0);

  // Date 格式化
  new Date().$formatTime(); // format time: yyyy-MM-dd hh-mm-ss
  new Date().$formatDate(); // format date: yyyy-MM-dd

  // document.querySelector
  $H2P(xpath);
  // document.querySelectorAll
  $H2P(xpath, false);