@vacantthinker/firefox-addon-framework-easy 2026.611.821 → 2026.611.1153

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.
Files changed (70) hide show
  1. package/README.md +0 -217
  2. package/dist/BaseORM.d.ts +41 -0
  3. package/dist/BaseORM.d.ts.map +1 -0
  4. package/dist/BaseORM.js +77 -0
  5. package/dist/browserDownload.d.ts +9 -0
  6. package/dist/browserDownload.d.ts.map +1 -0
  7. package/dist/browserDownload.js +10 -0
  8. package/dist/browserNotification.d.ts +8 -0
  9. package/dist/browserNotification.d.ts.map +1 -0
  10. package/dist/browserNotification.js +17 -0
  11. package/dist/browserRuntime.d.ts +41 -0
  12. package/dist/browserRuntime.d.ts.map +1 -0
  13. package/dist/browserRuntime.js +61 -0
  14. package/dist/browserTab.d.ts +34 -0
  15. package/dist/browserTab.d.ts.map +1 -0
  16. package/dist/browserTab.js +105 -0
  17. package/dist/generate.d.ts +13 -0
  18. package/dist/generate.d.ts.map +1 -0
  19. package/dist/generate.js +99 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +15 -0
  23. package/dist/opStorage.d.ts +40 -0
  24. package/dist/opStorage.d.ts.map +1 -0
  25. package/dist/opStorage.js +57 -0
  26. package/dist/opTab.d.ts +82 -0
  27. package/dist/opTab.d.ts.map +1 -0
  28. package/dist/opTab.js +152 -0
  29. package/dist/serviceCommon.d.ts +8 -0
  30. package/dist/serviceCommon.d.ts.map +1 -0
  31. package/dist/serviceCommon.js +21 -0
  32. package/dist/serviceFetch.d.ts +23 -0
  33. package/dist/serviceFetch.d.ts.map +1 -0
  34. package/dist/serviceFetch.js +38 -0
  35. package/dist/serviceGet.d.ts +13 -0
  36. package/dist/serviceGet.d.ts.map +1 -0
  37. package/dist/serviceGet.js +24 -0
  38. package/dist/serviceOpContent.d.ts +24 -0
  39. package/dist/serviceOpContent.d.ts.map +1 -0
  40. package/dist/serviceOpContent.js +69 -0
  41. package/dist/serviceOpJavascript.d.ts +41 -0
  42. package/dist/serviceOpJavascript.d.ts.map +1 -0
  43. package/dist/serviceOpJavascript.js +182 -0
  44. package/dist/servicePure.d.ts +18 -0
  45. package/dist/servicePure.d.ts.map +1 -0
  46. package/dist/servicePure.js +51 -0
  47. package/dist/serviceUpdateTabStyle.d.ts +17 -0
  48. package/dist/serviceUpdateTabStyle.d.ts.map +1 -0
  49. package/dist/serviceUpdateTabStyle.js +63 -0
  50. package/package.json +11 -4
  51. package/.github/workflows/npm-publish.yml +0 -34
  52. package/index.js +0 -17
  53. package/publish.sh +0 -81
  54. package/src/BaseORM.js +0 -66
  55. package/src/DomainORM.js +0 -11
  56. package/src/browserDownload.js +0 -23
  57. package/src/browserNotification.js +0 -22
  58. package/src/browserRuntime.js +0 -65
  59. package/src/browserRuntimeOnMessageCommon.js +0 -50
  60. package/src/browserTab.js +0 -138
  61. package/src/generate.js +0 -177
  62. package/src/opStorage.js +0 -76
  63. package/src/opTab.js +0 -237
  64. package/src/serviceCommon.js +0 -22
  65. package/src/serviceFetch.js +0 -65
  66. package/src/serviceGet.js +0 -31
  67. package/src/serviceOpContent.js +0 -83
  68. package/src/serviceOpJavascript.js +0 -346
  69. package/src/servicePure.js +0 -42
  70. package/src/serviceUpdateTabStyle.js +0 -130
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Common Node.js script template with interactive error handling.
3
+ */
4
+ function getMkvMergeNodeScript(videoInfo, mkvMergePath, openCommand) {
5
+ const { vid, videoTitle } = videoInfo;
6
+ return `
7
+ const path = require('path');
8
+ const fs = require('fs');
9
+ const { execSync } = require('child_process');
10
+ const readline = require('readline');
11
+
12
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
13
+
14
+ // Interactive helper to wait for user input before exiting
15
+ const waitAndExit = (msg, isError = true) => {
16
+ if (isError) console.error('\\n[ERROR]: ' + msg);
17
+ else console.log('\\n[INFO]: ' + msg);
18
+
19
+ rl.question('\\nPress Enter to exit...', () => {
20
+ rl.close();
21
+ process.exit(isError ? 1 : 0);
22
+ });
23
+ };
24
+
25
+ const { vid, videoTitle } = ${JSON.stringify(videoInfo)};
26
+ const pathDownload = __dirname;
27
+ const pathMKVOutput = path.join(pathDownload, \`\${videoTitle}.mkv\`);
28
+ const pathOutput = path.join(pathDownload, \`\${vid}.mkv\`);
29
+ const pathInputAudio = path.join(pathDownload, \`\${vid}.mp3\`);
30
+ const pathInputVideo = path.join(pathDownload, \`\${vid}.mp4\`);
31
+
32
+ if (fs.existsSync("${mkvMergePath}")) {
33
+ console.log('Merging: ' + videoTitle);
34
+
35
+ const cmd = [
36
+ '"${mkvMergePath}"',
37
+ '-o', '"' + pathOutput + '"',
38
+ '--no-video', '"' + pathInputAudio + '"',
39
+ '--no-audio', '"' + pathInputVideo + '"'
40
+ ].join(' ');
41
+
42
+ try {
43
+ execSync(cmd, { stdio: 'inherit' });
44
+
45
+ // Cleanup temporary files
46
+ if (fs.existsSync(pathInputVideo)) fs.unlinkSync(pathInputVideo);
47
+ if (fs.existsSync(pathInputAudio)) fs.unlinkSync(pathInputAudio);
48
+
49
+ // Finalize
50
+ fs.renameSync(pathOutput, pathMKVOutput);
51
+
52
+ console.log('Merge complete.');
53
+ // Optional: open the file
54
+ if ("${openCommand}") {
55
+ execSync(\`\${"${openCommand}"} "\${pathMKVOutput}"\`);
56
+ }
57
+ waitAndExit('Process completed successfully.', false);
58
+ } catch (err) {
59
+ waitAndExit('Processing failed: ' + err.message);
60
+ }
61
+ } else {
62
+ waitAndExit('mkvmerge not found at: ${mkvMergePath}. Please check installation.');
63
+ }
64
+ `;
65
+ }
66
+ /**
67
+ * Generates an executable script for Windows.
68
+ */
69
+ export function generateMkvScriptForSystemWindows(videoInfo) {
70
+ const nodeScript = getMkvMergeNodeScript(videoInfo, 'C:\\Program Files\\MKVToolNix\\mkvmerge.exe', '');
71
+ return `(function() {
72
+ const fs = require('fs');
73
+ ${nodeScript}
74
+
75
+ // Cleanup script file after user presses enter
76
+ // (Wait for process exit handled inside getMkvMergeNodeScript)
77
+ })();`;
78
+ }
79
+ /**
80
+ * Generates a bash script for Fedora.
81
+ */
82
+ export function generateMkvScriptForSystemFedora(videoInfo) {
83
+ const nodeScript = getMkvMergeNodeScript(videoInfo, '/usr/bin/mkvmerge', 'xdg-open');
84
+ return `#!/usr/bin/env bash
85
+
86
+ # Ensure execution in a visible terminal window
87
+ if [ -z "$VTE_VERSION" ] && [ -z "$ALACRITTY_WINDOW_ID" ] && [ -z "$KITTY_WINDOW_ID" ] && [ "$1" != "--child" ]; then
88
+ gnome-terminal -- "$0" --child
89
+ exit 0
90
+ fi
91
+
92
+ # Run Node.js logic
93
+ node << 'EOF'
94
+ ${nodeScript}
95
+ EOF
96
+
97
+ rm -- "$0"
98
+ `;
99
+ }
@@ -0,0 +1,16 @@
1
+ export * from './BaseORM';
2
+ export * from './browserDownload';
3
+ export * from './browserNotification';
4
+ export * from './browserRuntime';
5
+ export * from './browserTab';
6
+ export * from './generate';
7
+ export * from './opStorage';
8
+ export * from './opTab';
9
+ export * from './serviceCommon';
10
+ export * from './serviceFetch';
11
+ export * from './serviceGet';
12
+ export * from './serviceOpContent';
13
+ export * from './serviceOpJavascript';
14
+ export * from './servicePure';
15
+ export * from './serviceUpdateTabStyle';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export * from './BaseORM';
2
+ export * from './browserDownload';
3
+ export * from './browserNotification';
4
+ export * from './browserRuntime';
5
+ export * from './browserTab';
6
+ export * from './generate';
7
+ export * from './opStorage';
8
+ export * from './opTab';
9
+ export * from './serviceCommon';
10
+ export * from './serviceFetch';
11
+ export * from './serviceGet';
12
+ export * from './serviceOpContent';
13
+ export * from './serviceOpJavascript';
14
+ export * from './servicePure';
15
+ export * from './serviceUpdateTabStyle';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Checks if a key exists in local storage.
3
+ * @param key The key to check.
4
+ * @returns Promise resolving to true if key exists, false otherwise.
5
+ */
6
+ export declare function stoOpCheck(key: string): Promise<boolean>;
7
+ /**
8
+ * Retrieves a value from local storage by key.
9
+ * @param key The key to retrieve.
10
+ * @returns Promise resolving to the stored value or null if not found.
11
+ */
12
+ export declare function stoOpGet<T = any>(key: string): Promise<T | null>;
13
+ /**
14
+ * Retrieves all items from local storage.
15
+ * @returns Promise resolving to an object containing all storage items.
16
+ */
17
+ export declare function stoOpGetAll<T = Record<string, any>>(): Promise<T>;
18
+ /**
19
+ * Queries keys that start with a specific prefix.
20
+ * @param prefix The prefix to filter keys.
21
+ * @returns Promise resolving to an array of matching keys.
22
+ */
23
+ export declare function stoOpQueryStartWith(prefix: string): Promise<string[]>;
24
+ /**
25
+ * Sets a value in local storage.
26
+ * @param key The key to set.
27
+ * @param value The value to store.
28
+ */
29
+ export declare function stoOpSet(key: string, value: any): Promise<void>;
30
+ /**
31
+ * Removes a key from local storage.
32
+ * @param key The key to remove.
33
+ */
34
+ export declare function stoOpRem(key: string): Promise<void>;
35
+ /**
36
+ * Sets a key to null in local storage.
37
+ * @param key The key to set to null.
38
+ */
39
+ export declare function stoOpSetNull(key: string): Promise<void>;
40
+ //# sourceMappingURL=opStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opStorage.d.ts","sourceRoot":"","sources":["../src/opStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG9D;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAGtE;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAGvE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAG3E;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAErE;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Checks if a key exists in local storage.
3
+ * @param key The key to check.
4
+ * @returns Promise resolving to true if key exists, false otherwise.
5
+ */
6
+ export async function stoOpCheck(key) {
7
+ const result = await browser.storage.local.get(key);
8
+ return key in result;
9
+ }
10
+ /**
11
+ * Retrieves a value from local storage by key.
12
+ * @param key The key to retrieve.
13
+ * @returns Promise resolving to the stored value or null if not found.
14
+ */
15
+ export async function stoOpGet(key) {
16
+ const result = await browser.storage.local.get(key);
17
+ return result[key] !== undefined ? result[key] : null;
18
+ }
19
+ /**
20
+ * Retrieves all items from local storage.
21
+ * @returns Promise resolving to an object containing all storage items.
22
+ */
23
+ export async function stoOpGetAll() {
24
+ const result = await browser.storage.local.get();
25
+ return result;
26
+ }
27
+ /**
28
+ * Queries keys that start with a specific prefix.
29
+ * @param prefix The prefix to filter keys.
30
+ * @returns Promise resolving to an array of matching keys.
31
+ */
32
+ export async function stoOpQueryStartWith(prefix) {
33
+ const allItems = await browser.storage.local.get();
34
+ return Object.keys(allItems).filter((key) => key.startsWith(prefix));
35
+ }
36
+ /**
37
+ * Sets a value in local storage.
38
+ * @param key The key to set.
39
+ * @param value The value to store.
40
+ */
41
+ export async function stoOpSet(key, value) {
42
+ await browser.storage.local.set({ [key]: value });
43
+ }
44
+ /**
45
+ * Removes a key from local storage.
46
+ * @param key The key to remove.
47
+ */
48
+ export async function stoOpRem(key) {
49
+ await browser.storage.local.remove(key);
50
+ }
51
+ /**
52
+ * Sets a key to null in local storage.
53
+ * @param key The key to set to null.
54
+ */
55
+ export async function stoOpSetNull(key) {
56
+ await stoOpSet(key, null);
57
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Interface representing a Tab with an explicitly defined tabId.
3
+ */
4
+ export interface EnhancedTab extends browser.tabs.Tab {
5
+ tabId: number;
6
+ }
7
+ /**
8
+ * Enhances a standard tab object by attaching its ID to the 'tabId' property.
9
+ */
10
+ export declare function tabOpEnhance(tab: browser.tabs.Tab): EnhancedTab | null;
11
+ /**
12
+ * Creates a standard tab.
13
+ */
14
+ export declare function tabOpCreate(properties: browser.tabs._CreateCreateProperties): Promise<EnhancedTab>;
15
+ interface TabOpCreateNearOptions {
16
+ properties: browser.tabs._CreateCreateProperties;
17
+ previousTabId: number | undefined;
18
+ }
19
+ /**
20
+ * Creates a new tab positioned immediately after a specified existing tab.
21
+ */
22
+ export declare function tabOpCreateNear(options: TabOpCreateNearOptions): Promise<EnhancedTab>;
23
+ /**
24
+ * Creates a tab in the background (inactive and muted).
25
+ */
26
+ export declare function tabOpCreateActiveFalse(properties: browser.tabs._CreateCreateProperties): Promise<EnhancedTab>;
27
+ /**
28
+ * Creates a new window and returns its primary tab.
29
+ */
30
+ export declare function tabOpCreateByWindow(url: string): Promise<EnhancedTab | undefined>;
31
+ /**
32
+ * Retrieves details about the specified tab.
33
+ */
34
+ export declare function tabOpGet(tabId: number): Promise<browser.tabs.Tab>;
35
+ /**
36
+ * Retrieves all tabs across all windows.
37
+ */
38
+ export declare function tabOpQueryAll(): Promise<browser.tabs.Tab[]>;
39
+ /**
40
+ * Retrieves an array of tab IDs matching the URL pattern.
41
+ */
42
+ export declare function tabOpQueryUrl(urlQuery: string): Promise<number[]>;
43
+ /**
44
+ * Finds all tabs matching the URL pattern and removes them simultaneously.
45
+ */
46
+ export declare function tabOpQueryUrlThenRemove(urlQuery: string): Promise<void>;
47
+ /**
48
+ * Reloads the given tab.
49
+ * @param tabId The tab ID to reload.
50
+ * @param bypassCache Whether to bypass the cache.
51
+ */
52
+ export declare function tabOpReload(tabId: number, bypassCache?: boolean): Promise<void>;
53
+ /**
54
+ * Closes one or more tabs.
55
+ */
56
+ export declare function tabOpRemove(tabId: number | number[]): Promise<void>;
57
+ /**
58
+ * Hides one or more tabs.
59
+ */
60
+ export declare function tabOpHide(tabId: number | number[]): Promise<number[]>;
61
+ /**
62
+ * Modifies the properties of a tab.
63
+ */
64
+ export declare function tabOpUpdate(tabId: number, updateProperties: browser.tabs._UpdateUpdateProperties): Promise<EnhancedTab>;
65
+ /**
66
+ * Updates a tab to be inactive and muted.
67
+ */
68
+ export declare function tabOpUpdateActiveFalse(tabId: number): Promise<EnhancedTab>;
69
+ /**
70
+ * Focuses the window containing the tab, then highlights and activates the tab.
71
+ */
72
+ export declare function tabOpFocus(tabId: number): Promise<EnhancedTab>;
73
+ /**
74
+ * Injects CSS code into a page.
75
+ */
76
+ export declare function tabOpInsertCssCode(tabId: number, code: string): Promise<void>;
77
+ /**
78
+ * Removes CSS code that was previously injected into a page.
79
+ */
80
+ export declare function tabOpRemoveCssCode(tabId: number, code: string): Promise<void>;
81
+ export {};
82
+ //# sourceMappingURL=opTab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opTab.d.ts","sourceRoot":"","sources":["../src/opTab.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,IAAI,CAAC,GAAG;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,WAAW,GAAG,IAAI,CAGtE;AAsBD;;GAEG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAExG;AAED,UAAU,sBAAsB;IAC9B,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC;IACjD,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAc3F;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAMnH;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAIvF;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAEvE;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAEjE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGvE;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK7E;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5F;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE3E;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,GACrD,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAEhF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQpE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF"}
package/dist/opTab.js ADDED
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Enhances a standard tab object by attaching its ID to the 'tabId' property.
3
+ */
4
+ export function tabOpEnhance(tab) {
5
+ if (!tab || typeof tab.id !== 'number')
6
+ return null;
7
+ return { ...tab, tabId: tab.id };
8
+ }
9
+ /**
10
+ * Internal helper to unify tab creation.
11
+ */
12
+ async function _create(properties) {
13
+ const tab = await browser.tabs.create(properties);
14
+ const enhanced = tabOpEnhance(tab);
15
+ if (!enhanced)
16
+ throw new Error('Failed to enhance created tab: tabId is missing.');
17
+ return enhanced;
18
+ }
19
+ /**
20
+ * Internal helper to unify tab updates.
21
+ */
22
+ async function _update(tabId, properties) {
23
+ const tab = await browser.tabs.update(tabId, properties);
24
+ const enhanced = tabOpEnhance(tab);
25
+ if (!enhanced)
26
+ throw new Error(`Failed to enhance updated tab ${tabId}`);
27
+ return enhanced;
28
+ }
29
+ /**
30
+ * Creates a standard tab.
31
+ */
32
+ export async function tabOpCreate(properties) {
33
+ return _create(properties);
34
+ }
35
+ /**
36
+ * Creates a new tab positioned immediately after a specified existing tab.
37
+ */
38
+ export async function tabOpCreateNear(options) {
39
+ const { properties, previousTabId } = options;
40
+ if (previousTabId !== undefined) {
41
+ try {
42
+ const previousTab = await tabOpGet(previousTabId);
43
+ properties.index = previousTab.index + 1;
44
+ properties.openerTabId = previousTab.id;
45
+ }
46
+ catch {
47
+ // Ignore if source tab is invalid
48
+ }
49
+ }
50
+ return _create(properties);
51
+ }
52
+ /**
53
+ * Creates a tab in the background (inactive and muted).
54
+ */
55
+ export async function tabOpCreateActiveFalse(properties) {
56
+ return _create({
57
+ ...properties,
58
+ active: false,
59
+ muted: true,
60
+ });
61
+ }
62
+ /**
63
+ * Creates a new window and returns its primary tab.
64
+ */
65
+ export async function tabOpCreateByWindow(url) {
66
+ const window = await browser.windows.create({ url });
67
+ const tab = window.tabs?.[0];
68
+ return tab ? tabOpEnhance(tab) ?? undefined : undefined;
69
+ }
70
+ /**
71
+ * Retrieves details about the specified tab.
72
+ */
73
+ export async function tabOpGet(tabId) {
74
+ return await browser.tabs.get(tabId);
75
+ }
76
+ /**
77
+ * Retrieves all tabs across all windows.
78
+ */
79
+ export async function tabOpQueryAll() {
80
+ return await browser.tabs.query({});
81
+ }
82
+ /**
83
+ * Retrieves an array of tab IDs matching the URL pattern.
84
+ */
85
+ export async function tabOpQueryUrl(urlQuery) {
86
+ const tabs = await browser.tabs.query({ url: urlQuery });
87
+ return tabs.filter((t) => typeof t.id === 'number').map((t) => t.id);
88
+ }
89
+ /**
90
+ * Finds all tabs matching the URL pattern and removes them simultaneously.
91
+ */
92
+ export async function tabOpQueryUrlThenRemove(urlQuery) {
93
+ const ids = await tabOpQueryUrl(urlQuery);
94
+ if (ids.length > 0) {
95
+ await browser.tabs.remove(ids);
96
+ }
97
+ }
98
+ /**
99
+ * Reloads the given tab.
100
+ * @param tabId The tab ID to reload.
101
+ * @param bypassCache Whether to bypass the cache.
102
+ */
103
+ export async function tabOpReload(tabId, bypassCache = false) {
104
+ await browser.tabs.reload(tabId, { bypassCache });
105
+ }
106
+ /**
107
+ * Closes one or more tabs.
108
+ */
109
+ export async function tabOpRemove(tabId) {
110
+ await browser.tabs.remove(tabId);
111
+ }
112
+ /**
113
+ * Hides one or more tabs.
114
+ */
115
+ export async function tabOpHide(tabId) {
116
+ return await browser.tabs.hide(tabId);
117
+ }
118
+ /**
119
+ * Modifies the properties of a tab.
120
+ */
121
+ export async function tabOpUpdate(tabId, updateProperties) {
122
+ return _update(tabId, updateProperties);
123
+ }
124
+ /**
125
+ * Updates a tab to be inactive and muted.
126
+ */
127
+ export async function tabOpUpdateActiveFalse(tabId) {
128
+ return _update(tabId, { active: false, muted: true });
129
+ }
130
+ /**
131
+ * Focuses the window containing the tab, then highlights and activates the tab.
132
+ */
133
+ export async function tabOpFocus(tabId) {
134
+ const tab = await browser.tabs.get(tabId);
135
+ if (!tab || typeof tab.windowId !== 'number') {
136
+ throw new Error(`Tab ${tabId} not found or has no window.`);
137
+ }
138
+ await browser.windows.update(tab.windowId, { focused: true });
139
+ return _update(tabId, { active: true, highlighted: true });
140
+ }
141
+ /**
142
+ * Injects CSS code into a page.
143
+ */
144
+ export async function tabOpInsertCssCode(tabId, code) {
145
+ await browser.tabs.insertCSS(tabId, { code });
146
+ }
147
+ /**
148
+ * Removes CSS code that was previously injected into a page.
149
+ */
150
+ export async function tabOpRemoveCssCode(tabId, code) {
151
+ await browser.tabs.removeCSS(tabId, { code });
152
+ }
@@ -0,0 +1,8 @@
1
+ import { DownloadParams } from './browserDownload';
2
+ /**
3
+ * Service to handle download operations.
4
+ * Attempts a full download with filename; if it fails, retries with downlink only.
5
+ * * @param params The download parameters.
6
+ */
7
+ export declare function serviceDownloadByDownlink(params: DownloadParams): Promise<void>;
8
+ //# sourceMappingURL=serviceCommon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceCommon.d.ts","sourceRoot":"","sources":["../src/serviceCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAI5E;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrF"}
@@ -0,0 +1,21 @@
1
+ import { browserDownloadByDownlink } from './browserDownload';
2
+ import { browserNotificationCreate } from './browserNotification';
3
+ /**
4
+ * Service to handle download operations.
5
+ * Attempts a full download with filename; if it fails, retries with downlink only.
6
+ * * @param params The download parameters.
7
+ */
8
+ export async function serviceDownloadByDownlink(params) {
9
+ const { filename, downlink } = params;
10
+ try {
11
+ // Attempt 1: Full download with provided parameters
12
+ await browserDownloadByDownlink(params);
13
+ await browserNotificationCreate(`downloading! ${filename ?? 'file'}`);
14
+ }
15
+ catch (error) {
16
+ // Notify about the failure
17
+ await browserNotificationCreate(`reason=${error}`);
18
+ // Attempt 2: Fallback retry using only the downlink
19
+ await browserDownloadByDownlink({ downlink });
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Interface representing the structure of an Aria2 request.
3
+ */
4
+ export interface Aria2Request {
5
+ downlink: string;
6
+ filename?: string | null;
7
+ rpcSecret: string;
8
+ rpcPort: string;
9
+ }
10
+ /**
11
+ * Generic service to perform POST requests with JSON content.
12
+ * @param url The target URL.
13
+ * @param body The request payload.
14
+ * @returns Promise<Response>
15
+ */
16
+ export declare function servicePostJson(url: string, body: any): Promise<Response>;
17
+ /**
18
+ * Service to send download data to a local Aria2 instance via JSON-RPC.
19
+ * @param request The Aria2 request parameters.
20
+ * @returns Promise<Response>
21
+ */
22
+ export declare function serviceSendDataToLocalAria2(request: Aria2Request): Promise<Response>;
23
+ //# sourceMappingURL=serviceFetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceFetch.d.ts","sourceRoot":"","sources":["../src/serviceFetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAS/E;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoB1F"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Generic service to perform POST requests with JSON content.
3
+ * @param url The target URL.
4
+ * @param body The request payload.
5
+ * @returns Promise<Response>
6
+ */
7
+ export async function servicePostJson(url, body) {
8
+ return await fetch(url, {
9
+ method: 'POST',
10
+ headers: {
11
+ 'Content-Type': 'application/json;charset=UTF-8',
12
+ 'Accept': 'application/json',
13
+ },
14
+ body: JSON.stringify(body),
15
+ });
16
+ }
17
+ /**
18
+ * Service to send download data to a local Aria2 instance via JSON-RPC.
19
+ * @param request The Aria2 request parameters.
20
+ * @returns Promise<Response>
21
+ */
22
+ export async function serviceSendDataToLocalAria2(request) {
23
+ const { downlink, filename, rpcSecret, rpcPort } = request;
24
+ // Construct JSON-RPC parameters
25
+ const params = [`token:${rpcSecret}`, [downlink]];
26
+ if (filename) {
27
+ params.push({ out: filename });
28
+ }
29
+ // Construct JSON-RPC payload
30
+ const payload = {
31
+ jsonrpc: '2.0',
32
+ id: 'aria2-service',
33
+ method: 'aria2.addUri',
34
+ params,
35
+ };
36
+ const url = `http://localhost:${rpcPort}/jsonrpc`;
37
+ return await servicePostJson(url, payload);
38
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Extracts the hostname from a given URL string.
3
+ * @param url The full URL string.
4
+ * @returns The domain/hostname.
5
+ */
6
+ export declare function serviceGetDomainByUrl(url: string): string;
7
+ /**
8
+ * Generates a timestamp string in the format: YYYY_M_D_Hh_Mm_Ss_ms
9
+ * e.g., 2026_6_11_10h_30m_15s_450
10
+ * @returns The formatted timestamp string.
11
+ */
12
+ export declare function serviceGetCurrentDateYYYYMMDDHHMMSS(): string;
13
+ //# sourceMappingURL=serviceGet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceGet.d.ts","sourceRoot":"","sources":["../src/serviceGet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAY5D"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Extracts the hostname from a given URL string.
3
+ * @param url The full URL string.
4
+ * @returns The domain/hostname.
5
+ */
6
+ export function serviceGetDomainByUrl(url) {
7
+ return new URL(url).hostname;
8
+ }
9
+ /**
10
+ * Generates a timestamp string in the format: YYYY_M_D_Hh_Mm_Ss_ms
11
+ * e.g., 2026_6_11_10h_30m_15s_450
12
+ * @returns The formatted timestamp string.
13
+ */
14
+ export function serviceGetCurrentDateYYYYMMDDHHMMSS() {
15
+ const date = new Date();
16
+ const year = date.getFullYear();
17
+ const month = date.getMonth() + 1;
18
+ const day = date.getDate();
19
+ const hours = date.getHours();
20
+ const minutes = date.getMinutes();
21
+ const seconds = date.getSeconds();
22
+ const milliseconds = date.getMilliseconds();
23
+ return `${year}_${month}_${day}_${hours}h_${minutes}m_${seconds}s_${milliseconds}`;
24
+ }
@@ -0,0 +1,24 @@
1
+ import { VideoInfo } from './generate';
2
+ /**
3
+ * Copies text content to the system clipboard.
4
+ */
5
+ export declare function serviceCopyContentToClipboard(data: string): Promise<void>;
6
+ /**
7
+ * Saves content to a local file.
8
+ * @param content The content string.
9
+ * @param filename The base filename.
10
+ * @param ext The file extension.
11
+ */
12
+ export declare function serviceSaveContentToLocal(content: string, filename: string, ext?: string): void;
13
+ /**
14
+ * Generates an MKVToolNix script based on the current OS.
15
+ * @param videoInfo - The object containing vid and videoTitle.
16
+ */
17
+ export declare function serviceGenerateMkvToolNixScript(videoInfo: VideoInfo): Promise<void>;
18
+ /**
19
+ * Cleans a string to make it a valid filename.
20
+ * @param value The raw string.
21
+ * @returns A cleaned filename string.
22
+ */
23
+ export declare function serviceRemoveIllegalWord(value: string): string;
24
+ //# sourceMappingURL=serviceOpContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceOpContent.d.ts","sourceRoot":"","sources":["../src/serviceOpContent.ts"],"names":[],"mappings":"AACA,OAAO,EAE8B,SAAS,EAC7C,MAAM,YAAY,CAAC;AAYpB;;GAEG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAc,GAAG,IAAI,CActG;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB9D"}