@whitesev/utils 2.11.3 → 2.11.5
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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +54 -3
- 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 +20 -0
- package/package.json +1 -1
- package/src/Utils.ts +73 -2
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.5";
|
|
241
241
|
|
|
242
242
|
/* eslint-disable */
|
|
243
243
|
// ==UserScript==
|
|
@@ -7511,8 +7511,7 @@ class Utils {
|
|
|
7511
7511
|
}
|
|
7512
7512
|
async init() {
|
|
7513
7513
|
let copyStatus = false;
|
|
7514
|
-
|
|
7515
|
-
console.log(requestPermissionStatus);
|
|
7514
|
+
await this.requestClipboardPermission();
|
|
7516
7515
|
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7517
7516
|
try {
|
|
7518
7517
|
copyStatus = await this.copyDataByClipboard();
|
|
@@ -8480,6 +8479,58 @@ class Utils {
|
|
|
8480
8479
|
}
|
|
8481
8480
|
});
|
|
8482
8481
|
}
|
|
8482
|
+
calcPositionDistance(...args) {
|
|
8483
|
+
let position = {
|
|
8484
|
+
x: 0,
|
|
8485
|
+
y: 0,
|
|
8486
|
+
};
|
|
8487
|
+
let otherPosition = {
|
|
8488
|
+
x: 0,
|
|
8489
|
+
y: 0,
|
|
8490
|
+
};
|
|
8491
|
+
if (typeof args[0] === "object" && args[0] != null && typeof args[1] === "object" && args[1] != null) {
|
|
8492
|
+
position = args[0];
|
|
8493
|
+
otherPosition = args[1];
|
|
8494
|
+
}
|
|
8495
|
+
else if (args.length === 4) {
|
|
8496
|
+
position = {
|
|
8497
|
+
x: args[0],
|
|
8498
|
+
y: args[1],
|
|
8499
|
+
};
|
|
8500
|
+
otherPosition = {
|
|
8501
|
+
x: args[2],
|
|
8502
|
+
y: args[3],
|
|
8503
|
+
};
|
|
8504
|
+
}
|
|
8505
|
+
else {
|
|
8506
|
+
throw new Error("Invalid arguments");
|
|
8507
|
+
}
|
|
8508
|
+
if (typeof position.x === "string") {
|
|
8509
|
+
position.x = Number(position.x);
|
|
8510
|
+
}
|
|
8511
|
+
if (isNaN(position.x)) {
|
|
8512
|
+
throw new Error(`Invalid x: ${position.x}`);
|
|
8513
|
+
}
|
|
8514
|
+
if (typeof position.y === "string") {
|
|
8515
|
+
position.y = Number(position.y);
|
|
8516
|
+
}
|
|
8517
|
+
if (isNaN(position.y)) {
|
|
8518
|
+
throw new Error(`Invalid y: ${position.y}`);
|
|
8519
|
+
}
|
|
8520
|
+
if (typeof otherPosition.x === "string") {
|
|
8521
|
+
otherPosition.x = Number(otherPosition.x);
|
|
8522
|
+
}
|
|
8523
|
+
if (isNaN(otherPosition.x)) {
|
|
8524
|
+
throw new Error(`Invalid x: ${otherPosition.x}`);
|
|
8525
|
+
}
|
|
8526
|
+
if (typeof otherPosition.y === "string") {
|
|
8527
|
+
otherPosition.y = Number(otherPosition.y);
|
|
8528
|
+
}
|
|
8529
|
+
if (isNaN(otherPosition.y)) {
|
|
8530
|
+
throw new Error(`Invalid y: ${otherPosition.y}`);
|
|
8531
|
+
}
|
|
8532
|
+
return Math.sqrt(Math.pow(otherPosition.x - position.x, 2) + Math.pow(otherPosition.y - position.y, 2));
|
|
8533
|
+
}
|
|
8483
8534
|
}
|
|
8484
8535
|
const utils = new Utils();
|
|
8485
8536
|
|