@whitesev/utils 2.11.8 → 2.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +39 -5
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +39 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +39 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +39 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +39 -5
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +39 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Utils.d.ts +62 -20
- package/package.json +1 -1
- package/src/Utils.ts +76 -37
package/dist/index.esm.js
CHANGED
|
@@ -237,7 +237,7 @@ const clearTimeout$1 = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
|
|
|
237
237
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
238
238
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
239
239
|
|
|
240
|
-
const version = "2.11.
|
|
240
|
+
const version = "2.11.9";
|
|
241
241
|
|
|
242
242
|
/* eslint-disable */
|
|
243
243
|
// ==UserScript==
|
|
@@ -8339,6 +8339,20 @@ class Utils {
|
|
|
8339
8339
|
* 深度获取对象的某个属性
|
|
8340
8340
|
* @param target 待获取的对象
|
|
8341
8341
|
* @param handler 获取属性的回调
|
|
8342
|
+
* @example
|
|
8343
|
+
* Utils.queryProperty(window,(target)=>{
|
|
8344
|
+
* if(target.xxx){
|
|
8345
|
+
* return {
|
|
8346
|
+
* isFind: true,
|
|
8347
|
+
* data: target.xxx,
|
|
8348
|
+
* }
|
|
8349
|
+
* }else{
|
|
8350
|
+
* return {
|
|
8351
|
+
* isFind: false,
|
|
8352
|
+
* data: target.aabbcc,
|
|
8353
|
+
* }
|
|
8354
|
+
* }
|
|
8355
|
+
* })
|
|
8342
8356
|
*/
|
|
8343
8357
|
queryProperty(target, handler) {
|
|
8344
8358
|
if (target == null) {
|
|
@@ -8354,10 +8368,23 @@ class Utils {
|
|
|
8354
8368
|
* 异步-深度获取对象属性
|
|
8355
8369
|
* @param target 待获取的对象
|
|
8356
8370
|
* @param handler 获取属性的回调
|
|
8371
|
+
* @example
|
|
8372
|
+
* Utils.asyncQueryProperty(window, async (target)=>{
|
|
8373
|
+
* if(target.xxx){
|
|
8374
|
+
* return {
|
|
8375
|
+
* isFind: true,
|
|
8376
|
+
* data: target.xxx,
|
|
8377
|
+
* }
|
|
8378
|
+
* }else{
|
|
8379
|
+
* return {
|
|
8380
|
+
* isFind: false,
|
|
8381
|
+
* data: target.aabbcc,
|
|
8382
|
+
* }
|
|
8383
|
+
* }
|
|
8384
|
+
* })
|
|
8357
8385
|
*/
|
|
8358
8386
|
async asyncQueryProperty(target, handler) {
|
|
8359
8387
|
if (target == null) {
|
|
8360
|
-
// @ts-expect-error 空返回
|
|
8361
8388
|
return;
|
|
8362
8389
|
}
|
|
8363
8390
|
const handleResult = await handler(target);
|
|
@@ -8369,7 +8396,8 @@ class Utils {
|
|
|
8369
8396
|
/**
|
|
8370
8397
|
* 创建一个新的Utils实例
|
|
8371
8398
|
* @param option
|
|
8372
|
-
* @
|
|
8399
|
+
* @example
|
|
8400
|
+
* Utils.createUtils();
|
|
8373
8401
|
*/
|
|
8374
8402
|
createUtils(option) {
|
|
8375
8403
|
return new Utils(option);
|
|
@@ -8437,7 +8465,9 @@ class Utils {
|
|
|
8437
8465
|
/**
|
|
8438
8466
|
* 覆盖对象中的函数this指向
|
|
8439
8467
|
* @param target 需要覆盖的对象
|
|
8440
|
-
* @param
|
|
8468
|
+
* @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
|
|
8469
|
+
* @example
|
|
8470
|
+
* Utils.coverObjectFunctionThis({})
|
|
8441
8471
|
*/
|
|
8442
8472
|
coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
|
|
8443
8473
|
/**
|
|
@@ -8488,7 +8518,7 @@ class Utils {
|
|
|
8488
8518
|
/**
|
|
8489
8519
|
* 自动使用 Worker 执行 setTimeout
|
|
8490
8520
|
* @param callback 回调函数
|
|
8491
|
-
* @param
|
|
8521
|
+
* @param timeout 延迟时间,默认为0
|
|
8492
8522
|
*/
|
|
8493
8523
|
workerSetTimeout(callback, timeout = 0) {
|
|
8494
8524
|
try {
|
|
@@ -8559,6 +8589,10 @@ class Utils {
|
|
|
8559
8589
|
/**
|
|
8560
8590
|
* 判断页面中是否存在`worker-src`的CSP规则
|
|
8561
8591
|
* @param timeout 超时时间,默认为`1500ms`
|
|
8592
|
+
* @example
|
|
8593
|
+
* Utils.hasWorkerCSP().then((hasCSP) => {
|
|
8594
|
+
* console.log(hasCSP);
|
|
8595
|
+
* })
|
|
8562
8596
|
*/
|
|
8563
8597
|
hasWorkerCSP(timeout = 1500) {
|
|
8564
8598
|
return new Promise((resolve) => {
|