@jeniex/utils 1.0.22 → 1.0.23
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 +13 -3
- package/browser/index.d.ts +3 -1
- package/browser/index.js +13 -4
- package/package.json +1 -1
package/browser/index.cjs
CHANGED
|
@@ -130,11 +130,11 @@ if (typeof GM !== 'undefined') {
|
|
|
130
130
|
infoObject = GM.info;
|
|
131
131
|
// eslint-disable-next-line unicorn/no-negated-condition
|
|
132
132
|
}
|
|
133
|
-
else if (typeof GM_info
|
|
134
|
-
infoObject =
|
|
133
|
+
else if (typeof GM_info === 'undefined') {
|
|
134
|
+
infoObject = { script: { name: document.title } };
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
|
-
infoObject =
|
|
137
|
+
infoObject = GM_info;
|
|
138
138
|
}
|
|
139
139
|
const scriptName = infoObject.script.name;
|
|
140
140
|
/** The identifier of the script to be used in logging. */
|
|
@@ -361,6 +361,15 @@ async function pageLoad(completely) {
|
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
function saveFile(blob, fileName) {
|
|
365
|
+
const blobURL = URL.createObjectURL(blob);
|
|
366
|
+
const link = document.createElement('a');
|
|
367
|
+
link.href = blobURL;
|
|
368
|
+
link.download = fileName;
|
|
369
|
+
link.dispatchEvent(new MouseEvent('click'));
|
|
370
|
+
window.setTimeout(() => window.URL.revokeObjectURL(blobURL), 1000);
|
|
371
|
+
}
|
|
372
|
+
|
|
364
373
|
function createFlagMessage(flag) {
|
|
365
374
|
const { message: messageHeader, values, type } = flag;
|
|
366
375
|
let message = messageHeader;
|
|
@@ -467,6 +476,7 @@ exports.pageLoad = pageLoad;
|
|
|
467
476
|
exports.prompt = prompt;
|
|
468
477
|
exports.remove = remove;
|
|
469
478
|
exports.removeSearchParams = removeSearchParams;
|
|
479
|
+
exports.saveFile = saveFile;
|
|
470
480
|
exports.scriptName = scriptName;
|
|
471
481
|
exports.setSearchParam = setSearchParam;
|
|
472
482
|
exports.sleep = sleep;
|
package/browser/index.d.ts
CHANGED
|
@@ -125,6 +125,8 @@ declare function imageLoad(img: HTMLImageElement): Promise<void>;
|
|
|
125
125
|
*/
|
|
126
126
|
declare function pageLoad(completely?: boolean): Promise<void>;
|
|
127
127
|
|
|
128
|
+
declare function saveFile(blob: Blob, fileName: string): void;
|
|
129
|
+
|
|
128
130
|
interface FlagBase {
|
|
129
131
|
name: string;
|
|
130
132
|
message: string;
|
|
@@ -151,4 +153,4 @@ type Options = Record<string, FlagValue>;
|
|
|
151
153
|
|
|
152
154
|
declare function getOptions(flags: Flag[]): Promise<Options>;
|
|
153
155
|
|
|
154
|
-
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, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
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 };
|
package/browser/index.js
CHANGED
|
@@ -128,11 +128,11 @@ if (typeof GM !== 'undefined') {
|
|
|
128
128
|
infoObject = GM.info;
|
|
129
129
|
// eslint-disable-next-line unicorn/no-negated-condition
|
|
130
130
|
}
|
|
131
|
-
else if (typeof GM_info
|
|
132
|
-
infoObject =
|
|
131
|
+
else if (typeof GM_info === 'undefined') {
|
|
132
|
+
infoObject = { script: { name: document.title } };
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
-
infoObject =
|
|
135
|
+
infoObject = GM_info;
|
|
136
136
|
}
|
|
137
137
|
const scriptName = infoObject.script.name;
|
|
138
138
|
/** The identifier of the script to be used in logging. */
|
|
@@ -359,6 +359,15 @@ async function pageLoad(completely) {
|
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
function saveFile(blob, fileName) {
|
|
363
|
+
const blobURL = URL.createObjectURL(blob);
|
|
364
|
+
const link = document.createElement('a');
|
|
365
|
+
link.href = blobURL;
|
|
366
|
+
link.download = fileName;
|
|
367
|
+
link.dispatchEvent(new MouseEvent('click'));
|
|
368
|
+
window.setTimeout(() => window.URL.revokeObjectURL(blobURL), 1000);
|
|
369
|
+
}
|
|
370
|
+
|
|
362
371
|
function createFlagMessage(flag) {
|
|
363
372
|
const { message: messageHeader, values, type } = flag;
|
|
364
373
|
let message = messageHeader;
|
|
@@ -434,4 +443,4 @@ async function getOptions(flags) {
|
|
|
434
443
|
return options;
|
|
435
444
|
}
|
|
436
445
|
|
|
437
|
-
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, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
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 };
|