@whitesev/utils 2.11.8 → 2.11.10
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 +49 -6
- 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 +49 -6
- 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 +49 -6
- 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 +49 -6
- 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 +49 -6
- 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 +49 -6
- 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 +64 -22
- package/package.json +1 -1
- package/src/Utils.ts +89 -41
package/dist/index.cjs.js
CHANGED
|
@@ -239,7 +239,7 @@ const clearTimeout$1 = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
|
|
|
239
239
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
240
240
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
241
241
|
|
|
242
|
-
const version = "2.11.
|
|
242
|
+
const version = "2.11.10";
|
|
243
243
|
|
|
244
244
|
/* eslint-disable */
|
|
245
245
|
// ==UserScript==
|
|
@@ -6208,6 +6208,10 @@ class Utils {
|
|
|
6208
6208
|
if (typeof deviation !== "number" || Number.isNaN(deviation)) {
|
|
6209
6209
|
deviation = 10;
|
|
6210
6210
|
}
|
|
6211
|
+
// 最大值 2147483647
|
|
6212
|
+
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
6213
|
+
// 比较值 2000000000
|
|
6214
|
+
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
6211
6215
|
/** 坐标偏移 */
|
|
6212
6216
|
const positionDistance = 10;
|
|
6213
6217
|
const defaultCalcPostion = [];
|
|
@@ -6302,9 +6306,14 @@ class Utils {
|
|
|
6302
6306
|
left: maxRect.left,
|
|
6303
6307
|
};
|
|
6304
6308
|
}
|
|
6309
|
+
let calcZIndex = zIndex + deviation;
|
|
6310
|
+
if (calcZIndex >= maxZIndexCompare) {
|
|
6311
|
+
// 不要超过最大值
|
|
6312
|
+
calcZIndex = maxZIndexCompare;
|
|
6313
|
+
}
|
|
6305
6314
|
return {
|
|
6306
6315
|
/** 计算偏移量后的z-index值 */
|
|
6307
|
-
zIndex:
|
|
6316
|
+
zIndex: calcZIndex,
|
|
6308
6317
|
/** 获取到的最大的z-index值 */
|
|
6309
6318
|
originZIndex: zIndex,
|
|
6310
6319
|
/** 拥有最大z-index的元素 */
|
|
@@ -8341,6 +8350,20 @@ class Utils {
|
|
|
8341
8350
|
* 深度获取对象的某个属性
|
|
8342
8351
|
* @param target 待获取的对象
|
|
8343
8352
|
* @param handler 获取属性的回调
|
|
8353
|
+
* @example
|
|
8354
|
+
* Utils.queryProperty(window,(target)=>{
|
|
8355
|
+
* if(target.xxx){
|
|
8356
|
+
* return {
|
|
8357
|
+
* isFind: true,
|
|
8358
|
+
* data: target.xxx,
|
|
8359
|
+
* }
|
|
8360
|
+
* }else{
|
|
8361
|
+
* return {
|
|
8362
|
+
* isFind: false,
|
|
8363
|
+
* data: target.aabbcc,
|
|
8364
|
+
* }
|
|
8365
|
+
* }
|
|
8366
|
+
* })
|
|
8344
8367
|
*/
|
|
8345
8368
|
queryProperty(target, handler) {
|
|
8346
8369
|
if (target == null) {
|
|
@@ -8356,10 +8379,23 @@ class Utils {
|
|
|
8356
8379
|
* 异步-深度获取对象属性
|
|
8357
8380
|
* @param target 待获取的对象
|
|
8358
8381
|
* @param handler 获取属性的回调
|
|
8382
|
+
* @example
|
|
8383
|
+
* Utils.asyncQueryProperty(window, async (target)=>{
|
|
8384
|
+
* if(target.xxx){
|
|
8385
|
+
* return {
|
|
8386
|
+
* isFind: true,
|
|
8387
|
+
* data: target.xxx,
|
|
8388
|
+
* }
|
|
8389
|
+
* }else{
|
|
8390
|
+
* return {
|
|
8391
|
+
* isFind: false,
|
|
8392
|
+
* data: target.aabbcc,
|
|
8393
|
+
* }
|
|
8394
|
+
* }
|
|
8395
|
+
* })
|
|
8359
8396
|
*/
|
|
8360
8397
|
async asyncQueryProperty(target, handler) {
|
|
8361
8398
|
if (target == null) {
|
|
8362
|
-
// @ts-expect-error 空返回
|
|
8363
8399
|
return;
|
|
8364
8400
|
}
|
|
8365
8401
|
const handleResult = await handler(target);
|
|
@@ -8371,7 +8407,8 @@ class Utils {
|
|
|
8371
8407
|
/**
|
|
8372
8408
|
* 创建一个新的Utils实例
|
|
8373
8409
|
* @param option
|
|
8374
|
-
* @
|
|
8410
|
+
* @example
|
|
8411
|
+
* Utils.createUtils();
|
|
8375
8412
|
*/
|
|
8376
8413
|
createUtils(option) {
|
|
8377
8414
|
return new Utils(option);
|
|
@@ -8439,7 +8476,9 @@ class Utils {
|
|
|
8439
8476
|
/**
|
|
8440
8477
|
* 覆盖对象中的函数this指向
|
|
8441
8478
|
* @param target 需要覆盖的对象
|
|
8442
|
-
* @param
|
|
8479
|
+
* @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
|
|
8480
|
+
* @example
|
|
8481
|
+
* Utils.coverObjectFunctionThis({})
|
|
8443
8482
|
*/
|
|
8444
8483
|
coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
|
|
8445
8484
|
/**
|
|
@@ -8490,7 +8529,7 @@ class Utils {
|
|
|
8490
8529
|
/**
|
|
8491
8530
|
* 自动使用 Worker 执行 setTimeout
|
|
8492
8531
|
* @param callback 回调函数
|
|
8493
|
-
* @param
|
|
8532
|
+
* @param timeout 延迟时间,默认为0
|
|
8494
8533
|
*/
|
|
8495
8534
|
workerSetTimeout(callback, timeout = 0) {
|
|
8496
8535
|
try {
|
|
@@ -8561,6 +8600,10 @@ class Utils {
|
|
|
8561
8600
|
/**
|
|
8562
8601
|
* 判断页面中是否存在`worker-src`的CSP规则
|
|
8563
8602
|
* @param timeout 超时时间,默认为`1500ms`
|
|
8603
|
+
* @example
|
|
8604
|
+
* Utils.hasWorkerCSP().then((hasCSP) => {
|
|
8605
|
+
* console.log(hasCSP);
|
|
8606
|
+
* })
|
|
8564
8607
|
*/
|
|
8565
8608
|
hasWorkerCSP(timeout = 1500) {
|
|
8566
8609
|
return new Promise((resolve) => {
|