@jeniex/utils 1.0.24 → 1.0.26
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/browser/index.cjs +10 -5
- package/browser/index.d.ts +4 -0
- package/browser/index.js +10 -5
- package/package.json +1 -1
package/browser/index.cjs
CHANGED
|
@@ -307,14 +307,19 @@ function removeSearchParams(keys, fullURL) {
|
|
|
307
307
|
return updatedURL.join('');
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Checks if the VPN is active by accessing the router address.
|
|
312
|
+
* Tested on Opera browser build-in VPN only.
|
|
313
|
+
*/
|
|
310
314
|
async function checkVPN() {
|
|
311
|
-
let pass;
|
|
315
|
+
let pass = false;
|
|
312
316
|
try {
|
|
313
317
|
await fishXResponse('http://192.168.1.1/index.html', { method: 'HEAD' });
|
|
314
|
-
pass = false;
|
|
315
318
|
}
|
|
316
|
-
catch {
|
|
317
|
-
|
|
319
|
+
catch (exception) {
|
|
320
|
+
if (exception.message.includes('ended with 0 status')) {
|
|
321
|
+
pass = true;
|
|
322
|
+
}
|
|
318
323
|
}
|
|
319
324
|
if (pass === false) {
|
|
320
325
|
throw new Error('VPN is not enabled!');
|
|
@@ -368,7 +373,7 @@ async function imageLoad(img) {
|
|
|
368
373
|
* Waits for the page to load.
|
|
369
374
|
* @param completely Whether or not to wait for resources to load as well.
|
|
370
375
|
*/
|
|
371
|
-
async function pageLoad(completely) {
|
|
376
|
+
async function pageLoad(completely = false) {
|
|
372
377
|
return new Promise((resolve) => {
|
|
373
378
|
if (document.readyState === 'complete') {
|
|
374
379
|
resolve();
|
package/browser/index.d.ts
CHANGED
|
@@ -112,6 +112,10 @@ declare const logId: string;
|
|
|
112
112
|
/** The initial tab URL on the script run. */
|
|
113
113
|
declare const tabURL: string;
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Checks if the VPN is active by accessing the router address.
|
|
117
|
+
* Tested on Opera browser build-in VPN only.
|
|
118
|
+
*/
|
|
115
119
|
declare function checkVPN(): Promise<void>;
|
|
116
120
|
declare function checkVPNRandomly(): Promise<void>;
|
|
117
121
|
|
package/browser/index.js
CHANGED
|
@@ -305,14 +305,19 @@ function removeSearchParams(keys, fullURL) {
|
|
|
305
305
|
return updatedURL.join('');
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Checks if the VPN is active by accessing the router address.
|
|
310
|
+
* Tested on Opera browser build-in VPN only.
|
|
311
|
+
*/
|
|
308
312
|
async function checkVPN() {
|
|
309
|
-
let pass;
|
|
313
|
+
let pass = false;
|
|
310
314
|
try {
|
|
311
315
|
await fishXResponse('http://192.168.1.1/index.html', { method: 'HEAD' });
|
|
312
|
-
pass = false;
|
|
313
316
|
}
|
|
314
|
-
catch {
|
|
315
|
-
|
|
317
|
+
catch (exception) {
|
|
318
|
+
if (exception.message.includes('ended with 0 status')) {
|
|
319
|
+
pass = true;
|
|
320
|
+
}
|
|
316
321
|
}
|
|
317
322
|
if (pass === false) {
|
|
318
323
|
throw new Error('VPN is not enabled!');
|
|
@@ -366,7 +371,7 @@ async function imageLoad(img) {
|
|
|
366
371
|
* Waits for the page to load.
|
|
367
372
|
* @param completely Whether or not to wait for resources to load as well.
|
|
368
373
|
*/
|
|
369
|
-
async function pageLoad(completely) {
|
|
374
|
+
async function pageLoad(completely = false) {
|
|
370
375
|
return new Promise((resolve) => {
|
|
371
376
|
if (document.readyState === 'complete') {
|
|
372
377
|
resolve();
|