libs

JavaScript 库函数,以便调用

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/491971/1356811/libs.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

Author
Essence
Version
0.4
Created
2024-04-08
Updated
2024-04-08
Size
4.89 KB
License
N/A

库函数

使用

sleep

等待毫秒数

await sleep(3000)

waitElem

等待指定元素出现时,执行回调

  const click = (elem) => {
    console.log(TAG, "人机验证的选择框", elem)
    elem.click()
  }

  waitElem("div#challenge-stage span.mark", click)

readLocalStorageValues

读取所有本地存储LocalStorage的数据,可用正则排除键

const history = readLocalStorageValues(/^Hm_lvt/)

restoreLocalStorageValues

恢复备份的JSON数据到 LocalStorage

const json = `{"a": 123, "b": "test"}`

restoreLocalStorageValues(json)

containerToRow

让容器以 flex row 显示子元素

const root = document.querySelector("body")

containerToRow(root)

toast

显示通知消息

toast.default("低优先级消息", elemBody)
toast.primary("普通消息", elemBody)
toast.success("成功消息", elemBody)
toast.warning("警告消息", elemBody, 10 * 1000)
toast.danger("危险消息", elemBody, 30 * 1000)

showDialog

显示对话框

window.addEventListener('load', () => {
    const element = document.createElement('p');
    element.textContent = 'Some Content';

    showDialog('Title', element, null);
});