@whitesev/utils 2.11.0 → 2.11.2
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 +44 -11
- 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 +44 -11
- 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 +44 -11
- 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 +44 -11
- 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 +44 -11
- 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 +44 -11
- 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 +2 -1
- package/package.json +1 -1
- package/src/Utils.ts +47 -13
package/dist/index.umd.js
CHANGED
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
244
244
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
245
245
|
|
|
246
|
-
const version = "2.11.
|
|
246
|
+
const version = "2.11.2";
|
|
247
247
|
|
|
248
248
|
/* eslint-disable */
|
|
249
249
|
// ==UserScript==
|
|
@@ -7995,9 +7995,22 @@
|
|
|
7995
7995
|
return result;
|
|
7996
7996
|
}
|
|
7997
7997
|
else {
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
7998
|
+
const compareSet = new Set(compareArrayData);
|
|
7999
|
+
const result = [];
|
|
8000
|
+
for (let i = 0; i < uniqueArrayData.length; i++) {
|
|
8001
|
+
const item = uniqueArrayData[i];
|
|
8002
|
+
let flag = false;
|
|
8003
|
+
for (const compareItem of compareSet) {
|
|
8004
|
+
if (compareFun(item, compareItem)) {
|
|
8005
|
+
flag = true;
|
|
8006
|
+
break;
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
if (!flag) {
|
|
8010
|
+
result.push(item);
|
|
8011
|
+
}
|
|
8012
|
+
}
|
|
8013
|
+
return result;
|
|
8001
8014
|
}
|
|
8002
8015
|
}
|
|
8003
8016
|
/**
|
|
@@ -8377,10 +8390,13 @@
|
|
|
8377
8390
|
}
|
|
8378
8391
|
/**
|
|
8379
8392
|
* 判断页面中是否存在`worker-src`的CSP规则
|
|
8393
|
+
* @param timeout 超时时间,默认为`1500ms`
|
|
8380
8394
|
*/
|
|
8381
|
-
hasWorkerCSP() {
|
|
8395
|
+
hasWorkerCSP(timeout = 1500) {
|
|
8382
8396
|
return new Promise((resolve) => {
|
|
8383
8397
|
let flag = true;
|
|
8398
|
+
let timeId = void 0;
|
|
8399
|
+
let worker = void 0;
|
|
8384
8400
|
let workerBlobUrl = void 0;
|
|
8385
8401
|
const workerJs = /*js*/ `
|
|
8386
8402
|
(() => {
|
|
@@ -8396,11 +8412,26 @@
|
|
|
8396
8412
|
}
|
|
8397
8413
|
);
|
|
8398
8414
|
})();`;
|
|
8415
|
+
/**
|
|
8416
|
+
* 返回结果
|
|
8417
|
+
*/
|
|
8418
|
+
const finishCallBack = () => {
|
|
8419
|
+
clearTimeout(timeId);
|
|
8420
|
+
if (worker != null) {
|
|
8421
|
+
worker.terminate();
|
|
8422
|
+
}
|
|
8423
|
+
// 释放
|
|
8424
|
+
if (typeof workerBlobUrl === "string") {
|
|
8425
|
+
globalThis.URL.revokeObjectURL(workerBlobUrl);
|
|
8426
|
+
workerBlobUrl = void 0;
|
|
8427
|
+
}
|
|
8428
|
+
resolve(flag);
|
|
8429
|
+
};
|
|
8399
8430
|
try {
|
|
8400
8431
|
const workerScript = new Blob([workerJs], {
|
|
8401
8432
|
type: "application/javascript",
|
|
8402
8433
|
});
|
|
8403
|
-
workerBlobUrl =
|
|
8434
|
+
workerBlobUrl = globalThis.URL.createObjectURL(workerScript);
|
|
8404
8435
|
// @ts-expect-error
|
|
8405
8436
|
if (globalThis.trustedTypes && typeof globalThis.trustedTypes.createPolicy === "function") {
|
|
8406
8437
|
// 使用这个后虽然不报错,但是仍会有blob错误
|
|
@@ -8412,25 +8443,27 @@
|
|
|
8412
8443
|
});
|
|
8413
8444
|
workerBlobUrl = workerPolicy.createScriptURL(workerBlobUrl);
|
|
8414
8445
|
}
|
|
8415
|
-
|
|
8446
|
+
worker = new Worker(workerBlobUrl);
|
|
8416
8447
|
worker.onmessage = (data) => {
|
|
8417
8448
|
if (data.data.success) {
|
|
8418
8449
|
flag = false;
|
|
8450
|
+
finishCallBack();
|
|
8419
8451
|
}
|
|
8420
8452
|
};
|
|
8421
|
-
setTimeout(() => {
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
}, 500);
|
|
8453
|
+
timeId = setTimeout(() => {
|
|
8454
|
+
finishCallBack();
|
|
8455
|
+
}, timeout);
|
|
8425
8456
|
worker.postMessage("test");
|
|
8426
8457
|
}
|
|
8427
8458
|
catch {
|
|
8428
8459
|
flag = true;
|
|
8460
|
+
finishCallBack();
|
|
8429
8461
|
}
|
|
8430
8462
|
finally {
|
|
8431
8463
|
// 释放
|
|
8432
8464
|
if (typeof workerBlobUrl === "string") {
|
|
8433
8465
|
globalThis.URL.revokeObjectURL(workerBlobUrl);
|
|
8466
|
+
workerBlobUrl = void 0;
|
|
8434
8467
|
}
|
|
8435
8468
|
}
|
|
8436
8469
|
});
|