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