@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.iife.js
CHANGED
|
@@ -240,7 +240,7 @@ var Utils = (function () {
|
|
|
240
240
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
241
241
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
242
242
|
|
|
243
|
-
const version = "2.11.
|
|
243
|
+
const version = "2.11.9";
|
|
244
244
|
|
|
245
245
|
/* eslint-disable */
|
|
246
246
|
// ==UserScript==
|
|
@@ -8342,6 +8342,20 @@ var Utils = (function () {
|
|
|
8342
8342
|
* 深度获取对象的某个属性
|
|
8343
8343
|
* @param target 待获取的对象
|
|
8344
8344
|
* @param handler 获取属性的回调
|
|
8345
|
+
* @example
|
|
8346
|
+
* Utils.queryProperty(window,(target)=>{
|
|
8347
|
+
* if(target.xxx){
|
|
8348
|
+
* return {
|
|
8349
|
+
* isFind: true,
|
|
8350
|
+
* data: target.xxx,
|
|
8351
|
+
* }
|
|
8352
|
+
* }else{
|
|
8353
|
+
* return {
|
|
8354
|
+
* isFind: false,
|
|
8355
|
+
* data: target.aabbcc,
|
|
8356
|
+
* }
|
|
8357
|
+
* }
|
|
8358
|
+
* })
|
|
8345
8359
|
*/
|
|
8346
8360
|
queryProperty(target, handler) {
|
|
8347
8361
|
if (target == null) {
|
|
@@ -8357,10 +8371,23 @@ var Utils = (function () {
|
|
|
8357
8371
|
* 异步-深度获取对象属性
|
|
8358
8372
|
* @param target 待获取的对象
|
|
8359
8373
|
* @param handler 获取属性的回调
|
|
8374
|
+
* @example
|
|
8375
|
+
* Utils.asyncQueryProperty(window, async (target)=>{
|
|
8376
|
+
* if(target.xxx){
|
|
8377
|
+
* return {
|
|
8378
|
+
* isFind: true,
|
|
8379
|
+
* data: target.xxx,
|
|
8380
|
+
* }
|
|
8381
|
+
* }else{
|
|
8382
|
+
* return {
|
|
8383
|
+
* isFind: false,
|
|
8384
|
+
* data: target.aabbcc,
|
|
8385
|
+
* }
|
|
8386
|
+
* }
|
|
8387
|
+
* })
|
|
8360
8388
|
*/
|
|
8361
8389
|
async asyncQueryProperty(target, handler) {
|
|
8362
8390
|
if (target == null) {
|
|
8363
|
-
// @ts-expect-error 空返回
|
|
8364
8391
|
return;
|
|
8365
8392
|
}
|
|
8366
8393
|
const handleResult = await handler(target);
|
|
@@ -8372,7 +8399,8 @@ var Utils = (function () {
|
|
|
8372
8399
|
/**
|
|
8373
8400
|
* 创建一个新的Utils实例
|
|
8374
8401
|
* @param option
|
|
8375
|
-
* @
|
|
8402
|
+
* @example
|
|
8403
|
+
* Utils.createUtils();
|
|
8376
8404
|
*/
|
|
8377
8405
|
createUtils(option) {
|
|
8378
8406
|
return new Utils(option);
|
|
@@ -8440,7 +8468,9 @@ var Utils = (function () {
|
|
|
8440
8468
|
/**
|
|
8441
8469
|
* 覆盖对象中的函数this指向
|
|
8442
8470
|
* @param target 需要覆盖的对象
|
|
8443
|
-
* @param
|
|
8471
|
+
* @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
|
|
8472
|
+
* @example
|
|
8473
|
+
* Utils.coverObjectFunctionThis({})
|
|
8444
8474
|
*/
|
|
8445
8475
|
coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
|
|
8446
8476
|
/**
|
|
@@ -8491,7 +8521,7 @@ var Utils = (function () {
|
|
|
8491
8521
|
/**
|
|
8492
8522
|
* 自动使用 Worker 执行 setTimeout
|
|
8493
8523
|
* @param callback 回调函数
|
|
8494
|
-
* @param
|
|
8524
|
+
* @param timeout 延迟时间,默认为0
|
|
8495
8525
|
*/
|
|
8496
8526
|
workerSetTimeout(callback, timeout = 0) {
|
|
8497
8527
|
try {
|
|
@@ -8562,6 +8592,10 @@ var Utils = (function () {
|
|
|
8562
8592
|
/**
|
|
8563
8593
|
* 判断页面中是否存在`worker-src`的CSP规则
|
|
8564
8594
|
* @param timeout 超时时间,默认为`1500ms`
|
|
8595
|
+
* @example
|
|
8596
|
+
* Utils.hasWorkerCSP().then((hasCSP) => {
|
|
8597
|
+
* console.log(hasCSP);
|
|
8598
|
+
* })
|
|
8565
8599
|
*/
|
|
8566
8600
|
hasWorkerCSP(timeout = 1500) {
|
|
8567
8601
|
return new Promise((resolve) => {
|