@jeniex/utils 1.0.23 → 1.0.24
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 +23 -0
- package/browser/index.d.ts +4 -1
- package/browser/index.js +22 -1
- package/package.json +1 -1
package/browser/index.cjs
CHANGED
|
@@ -307,6 +307,27 @@ function removeSearchParams(keys, fullURL) {
|
|
|
307
307
|
return updatedURL.join('');
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
async function checkVPN() {
|
|
311
|
+
let pass;
|
|
312
|
+
try {
|
|
313
|
+
await fishXResponse('http://192.168.1.1/index.html', { method: 'HEAD' });
|
|
314
|
+
pass = false;
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
pass = true;
|
|
318
|
+
}
|
|
319
|
+
if (pass === false) {
|
|
320
|
+
throw new Error('VPN is not enabled!');
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async function checkVPNRandomly() {
|
|
324
|
+
// a 1/10 chance to check.
|
|
325
|
+
if (Math.floor(Math.random() * 10) === 0) {
|
|
326
|
+
await checkVPN();
|
|
327
|
+
console.log('%cPass check for VPN!', 'color: #04da79');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
310
331
|
function addStyle(css, parent = document.documentElement) {
|
|
311
332
|
const style = document.createElement('style');
|
|
312
333
|
style.setAttribute('type', 'text/css');
|
|
@@ -451,6 +472,8 @@ exports.addStyle = addStyle;
|
|
|
451
472
|
exports.alert = alert;
|
|
452
473
|
exports.asserted = asserted;
|
|
453
474
|
exports.capitalize = capitalize;
|
|
475
|
+
exports.checkVPN = checkVPN;
|
|
476
|
+
exports.checkVPNRandomly = checkVPNRandomly;
|
|
454
477
|
exports.confirm = confirm;
|
|
455
478
|
exports.fish = fish;
|
|
456
479
|
exports.fishResponse = fishResponse;
|
package/browser/index.d.ts
CHANGED
|
@@ -112,6 +112,9 @@ declare const logId: string;
|
|
|
112
112
|
/** The initial tab URL on the script run. */
|
|
113
113
|
declare const tabURL: string;
|
|
114
114
|
|
|
115
|
+
declare function checkVPN(): Promise<void>;
|
|
116
|
+
declare function checkVPNRandomly(): Promise<void>;
|
|
117
|
+
|
|
115
118
|
declare function addStyle(css: string, parent?: HTMLElement): HTMLStyleElement;
|
|
116
119
|
|
|
117
120
|
/**
|
|
@@ -153,4 +156,4 @@ type Options = Record<string, FlagValue>;
|
|
|
153
156
|
|
|
154
157
|
declare function getOptions(flags: Flag[]): Promise<Options>;
|
|
155
158
|
|
|
156
|
-
export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
159
|
+
export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
|
package/browser/index.js
CHANGED
|
@@ -305,6 +305,27 @@ function removeSearchParams(keys, fullURL) {
|
|
|
305
305
|
return updatedURL.join('');
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
async function checkVPN() {
|
|
309
|
+
let pass;
|
|
310
|
+
try {
|
|
311
|
+
await fishXResponse('http://192.168.1.1/index.html', { method: 'HEAD' });
|
|
312
|
+
pass = false;
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
pass = true;
|
|
316
|
+
}
|
|
317
|
+
if (pass === false) {
|
|
318
|
+
throw new Error('VPN is not enabled!');
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
async function checkVPNRandomly() {
|
|
322
|
+
// a 1/10 chance to check.
|
|
323
|
+
if (Math.floor(Math.random() * 10) === 0) {
|
|
324
|
+
await checkVPN();
|
|
325
|
+
console.log('%cPass check for VPN!', 'color: #04da79');
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
308
329
|
function addStyle(css, parent = document.documentElement) {
|
|
309
330
|
const style = document.createElement('style');
|
|
310
331
|
style.setAttribute('type', 'text/css');
|
|
@@ -443,4 +464,4 @@ async function getOptions(flags) {
|
|
|
443
464
|
return options;
|
|
444
465
|
}
|
|
445
466
|
|
|
446
|
-
export { $, $$, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
467
|
+
export { $, $$, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
|