@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
package/src/BaseORM.js DELETED
@@ -1,66 +0,0 @@
1
- import {stoOpCheck, stoOpGet, stoOpRem, stoOpSet} from './opStorage.js';
2
-
3
- /**
4
- * Abstract base class BaseORM.
5
- * Provides encapsulated CRUD operations for JSON-serializable Key-Value pairs.
6
- */
7
- export class BaseORM {
8
- #id;
9
- #fullStorageKey;
10
- #defaultValue;
11
-
12
- constructor(prefix, id, defaultValue = {}) {
13
- if (new.target === BaseORM) {
14
- throw new TypeError(
15
- 'Cannot construct BaseORM instances directly (Abstract Class).');
16
- }
17
- if (!prefix || !id) {
18
- throw new Error('Both prefix and id must be specified.');
19
- }
20
-
21
- this.#id = id;
22
- const formattedPrefix = prefix.endsWith(' ') ? prefix : `${prefix} `;
23
- this.#fullStorageKey = `${formattedPrefix}${id}`;
24
- this.#defaultValue = JSON.parse(JSON.stringify(defaultValue));
25
- }
26
-
27
- get id() {
28
- return this.#id;
29
- }
30
-
31
- get storageKey() {
32
- return this.#fullStorageKey;
33
- }
34
-
35
- async #exists() {
36
- return await stoOpCheck(this.#fullStorageKey);
37
- }
38
-
39
- async #initDefaultObject() {
40
- await stoOpSet(this.#fullStorageKey, this.#defaultValue);
41
- }
42
-
43
- async get() {
44
- if (!(await this.#exists())) {
45
- await this.#initDefaultObject();
46
- }
47
- return await stoOpGet(this.#fullStorageKey);
48
- }
49
-
50
- async set(value) {
51
- await stoOpSet(this.#fullStorageKey, value || this.#defaultValue);
52
- }
53
-
54
- async delete() {
55
- const previousValue = await this.get();
56
- await stoOpRem(this.#fullStorageKey);
57
- return previousValue;
58
- }
59
-
60
- async updateValueKeyValue(objectKey, objectValue) {
61
- const currentData = await this.get();
62
- currentData[objectKey] = objectValue;
63
- await this.set(currentData);
64
- return currentData;
65
- }
66
- }
package/src/DomainORM.js DELETED
@@ -1,11 +0,0 @@
1
- import {BaseORM} from './BaseORM.js';
2
-
3
- export class DomainORM extends BaseORM {
4
- constructor(domain) {
5
- super(`domainKey`, domain, {});
6
- }
7
-
8
- logKey() {
9
- console.info(this.id); // domainKey 123sdfsdf
10
- }
11
- }
@@ -1,23 +0,0 @@
1
- /**
2
- *
3
- * @param param0
4
- * @param param0.downlink{string}
5
- * @param param0.filename{string|null|undefined}
6
- * @returns {Promise<void>}
7
- */
8
- export async function browserDownloadByDownlink(
9
- {
10
- downlink,
11
- filename = null,
12
- }) {
13
- let url = downlink;
14
- /** @type {browser.downloads._DownloadOptions} */
15
- let options = {
16
- url,
17
- saveAs: false,
18
- };
19
- if (filename) {
20
- Object.assign(options, {filename});
21
- }
22
- await browser.downloads.download(options);
23
- }
@@ -1,22 +0,0 @@
1
- import {browserRuntimeManifestName} from './browserRuntime.js';
2
-
3
- /**
4
- *
5
- * @param content{ string}
6
- * @param title{string}
7
- * @returns {Promise<string>}
8
- */
9
- export async function browserNotificationCreate(
10
- content,
11
- title = browserRuntimeManifestName(),
12
- ) {
13
-
14
- const tag = 'browserNotificationCreate';
15
- let notificationId = `${tag}cake-noti`;
16
- await browser.notifications.create(notificationId, {
17
- type: 'basic',
18
- title,
19
- message: `${content}`,
20
- });
21
- return notificationId;
22
- }
@@ -1,65 +0,0 @@
1
- export function browserRuntimeReload() {
2
- browser.runtime.reload();
3
- }
4
-
5
- /**
6
- *
7
- * @param url{string}
8
- */
9
- export async function browserRuntimeSetUninstallURL(
10
- url = '',
11
- ) {
12
- await browser.runtime.setUninstallURL(url);
13
- }
14
-
15
- /**
16
- *
17
- * @param doWhat{function}
18
- */
19
- export function browserRuntimeOnUpdateAvailable(doWhat = null) {
20
- browser.runtime.onUpdateAvailable.addListener(async (details) => {
21
- if (doWhat) {
22
- await doWhat(details);
23
- }
24
- });
25
- }
26
-
27
- /**
28
- *
29
- * @param path{string}
30
- * @returns {string}
31
- */
32
- export function browserRuntimeGetURL(path) {
33
- return browser.runtime.getURL(path);
34
- }
35
-
36
- /**
37
- * @returns {browser._manifest.ExtensionID}
38
- */
39
- export function browserRuntimeGeckoId() {
40
- return browser.runtime.getManifest().browser_specific_settings.gecko.id;
41
- }
42
-
43
- /**
44
- *
45
- * @returns {Promise<browser.runtime.PlatformInfo>}
46
- */
47
- export async function browserRuntimePlatformInfo() {
48
- return await browser.runtime.getPlatformInfo();
49
- }
50
-
51
- /**
52
- * browser.runtime.getManifest().version;
53
- * @returns {string}
54
- */
55
- export function browserRuntimeManifestVersion() {
56
- return browser.runtime.getManifest().version;
57
- }
58
-
59
- /**
60
- * browser.runtime.getManifest().name;
61
- * @returns {string}
62
- */
63
- export function browserRuntimeManifestName() {
64
- return browser.runtime.getManifest().name;
65
- }
@@ -1,50 +0,0 @@
1
- import {tabOpFocus, tabOpRemove} from './opTab.js';
2
- import {serviceDownloadByDownlink} from './serviceCommon.js';
3
- import {browserTabSendMessage} from './browserTab.js';
4
- import {browserNotificationCreate} from './browserNotification.js';
5
-
6
- /**
7
- * Offer common act <=> function
8
- *
9
- * @param act{
10
- * |'actLog'
11
- * |'actMarco'
12
- * |'actRequestTabIdTabUrl'
13
- * |'actNotification'
14
- * |'actRemoveTab'
15
- * |'actFocusTab'
16
- * |'actDownloadFile'
17
- * |'actSendMessageToTab'
18
- * }
19
- * @param message
20
- * @param message.tabId{number}
21
- * @param sendResponse
22
- */
23
- export function browserRuntimeOnMessageCommon(act, message, sendResponse) {
24
- switch (act) {
25
- case 'actLog':
26
- console.log('act', act, 'message', message);
27
- break;
28
- case 'actMarco': //Marco Polo pool game
29
- sendResponse({status: 'Polo'});
30
- break;
31
- case 'actRequestTabIdTabUrl':
32
- sendResponse(message);
33
- break;
34
- case 'actNotification':
35
- browserNotificationCreate(message.content);
36
- break;
37
- case 'actRemoveTab':
38
- tabOpRemove(message.tabId);
39
- break;
40
- case 'actFocusTab':
41
- tabOpFocus(message.tabId);
42
- break;
43
- case 'actDownloadFile':
44
- serviceDownloadByDownlink(message);
45
- break;
46
- case 'actSendMessageToTab':
47
- browserTabSendMessage(message.tabId, message);
48
- break;
49
- }
50
- }
package/src/browserTab.js DELETED
@@ -1,138 +0,0 @@
1
- // @ts-check
2
-
3
- import {tabOpCreateNear, tabOpGet, tabOpRemove} from './opTab.js';
4
-
5
- export async function browserTabSendMessage(
6
- tabId,
7
- message,
8
- ) {
9
- await browser.tabs.sendMessage(tabId, message);
10
- }
11
-
12
- export function browserTabWaitReloadThenSendMessageToContentJs(message) {
13
- let tabId = message.tabId;
14
- browser.tabs.onUpdated.addListener(
15
- async function lis(
16
- tabId,
17
- changeInfo,
18
- ) {
19
- if (changeInfo.status === 'complete') {
20
- browser.tabs.onUpdated.removeListener(lis);
21
- await browserTabSendMessage(tabId, message);
22
- }
23
- }
24
- , {tabId, properties: ['status']});
25
- }
26
-
27
- /**
28
- * must has, url
29
- * @param message
30
- * @param message.tabId{number}
31
- * @param message.url{string}
32
- * @param message.focusNewTab{boolean}
33
- * @returns {Promise<void>}
34
- */
35
- export async function browserTabCreateToDownload(message) {
36
- let properties = {
37
- url: message.url,
38
- };
39
- if (message.tabId) {
40
- let tabId = message.tabId;
41
- try {
42
- await tabOpGet(tabId);
43
- Object.assign(properties, {tabId});
44
- } catch (e) {
45
- delete message.tabId;
46
- }
47
- }
48
-
49
- if (message?.focusNewTab !== undefined) {
50
- Object.assign(properties, {active: message.focusNewTab});
51
- }
52
-
53
- let {tabId} = await tabOpCreateNear(properties);
54
- browser.tabs.onUpdated.addListener(
55
- async function lis(
56
- tabId,
57
- changeInfo,
58
- ) {
59
- if (changeInfo.status === 'complete') {
60
- browser.tabs.onUpdated.removeListener(lis);
61
- // todo code here
62
- await tabOpRemove(tabId);
63
- }
64
- }
65
- , {tabId, properties: ['status']});
66
- }
67
-
68
- /**
69
- * Safely handles incoming messages to create tabs and send messages to content scripts.
70
- * * @param {Object} message - The message payload.
71
- * @param {number} [message.tabId] - Optional Tab ID to attach to.
72
- * @param {string} [message.url] - The URL to open.
73
- * @param {boolean} [message.focusNewTab] - Whether the newly created tab should be active.
74
- * @returns {Promise<void>}
75
- */
76
- export async function browserTabCreateNearSendMessageToContentJs(message = {}) {
77
- let properties = {
78
- url: message.url,
79
- };
80
-
81
- // Strictly check for tabId presence to prevent passing undefined.
82
- if (message.tabId !== undefined) {
83
- let tabId = message.tabId;
84
- try {
85
- await tabOpGet(tabId);
86
- Object.assign(properties, {tabId});
87
- } catch (e) {
88
- delete message.tabId;
89
- }
90
- }
91
-
92
- // Use optional chaining to safely extract nested properties.
93
- // Only assign 'active' if 'focusNewTab' was explicitly provided.
94
- if (message?.focusNewTab !== undefined) {
95
- Object.assign(properties, {active: message.focusNewTab});
96
- }
97
-
98
- let {tabId} = await tabOpCreateNear(properties);
99
-
100
- browser.tabs.onUpdated.addListener(
101
- async function lis(
102
- updatedTabId,
103
- changeInfo,
104
- ) {
105
- if (changeInfo.status === 'complete') {
106
- browser.tabs.onUpdated.removeListener(lis);
107
-
108
- // Execute further logic once the tab is completely loaded.
109
- await browserTabSendMessage(
110
- updatedTabId,
111
- Object.assign({}, message, {tabId: updatedTabId}),
112
- );
113
- }
114
- },
115
- {tabId, properties: ['status']},
116
- );
117
- }
118
-
119
- /**
120
- * tab exists, watch it, reload then close
121
- * @param param0
122
- * @param param0.tabId{number}
123
- */
124
- export function browserTabWaitReloadThenRemoveIt({tabId}) {
125
- browser.tabs.onUpdated.addListener(
126
- async function lis(
127
- tabId,
128
- changeInfo,
129
- ) {
130
- if (changeInfo.status === 'complete') {
131
- browser.tabs.onUpdated.removeListener(lis);
132
- // todo code here
133
- await tabOpRemove(tabId);
134
- }
135
- }
136
- , {tabId, properties: ['status']});
137
-
138
- }
package/src/generate.js DELETED
@@ -1,177 +0,0 @@
1
- /**
2
- *
3
- * @param videoInfo
4
- * @param videoInfo.vid{string}
5
- * @param videoInfo.videoTitle{string}
6
- * @return {string}
7
- */
8
- export function generateMkvScriptForSystemWindows(videoInfo) {
9
- return `if (true) {
10
- const path = require('path');
11
- const fs = require('fs');
12
- const {execSync, exec} = require('node:child_process');
13
- let pathDownload = path.join(__dirname);
14
- let dot = '.';
15
- let extMKV = 'mkv';
16
-
17
- let {vid, videoTitle} = ${JSON.stringify(videoInfo)};
18
- let playVideoAfterMerged = true;
19
- let pathToMkvmerge = 'C:\\\\Program Files\\\\MKVToolNix\\\\mkvmerge.exe';
20
-
21
- let pathMKVOutput = path.join(pathDownload, videoTitle.concat(dot, extMKV));
22
- let pathOutput = path.join(pathDownload, vid.concat(dot, extMKV));
23
- let pathInputAudio = path.join(pathDownload, vid.concat(dot, "mp3"));
24
- let pathInputVideo = path.join(pathDownload, vid.concat(dot, "mp4"));
25
- let pathJsFile = path.join(__filename);
26
-
27
- if (
28
- fs.existsSync(pathToMkvmerge)
29
- ) {
30
-
31
- console.log('');
32
- console.log(['file check ok!', videoTitle].join(' '));
33
-
34
- let cmd_merge = [
35
- [pathToMkvmerge].map(v => '"' + v + '"').join(''),
36
-
37
- '-o',
38
- [pathOutput]
39
- .map(value => '"' + value + '"')
40
- .join(' '),
41
-
42
- '--no-video',
43
- [pathInputAudio]
44
- .map(value => '"' + value + '"')
45
- .join(' '),
46
-
47
- '--no-audio',
48
- [pathInputVideo]
49
- .map(value => '"' + value + '"')
50
- .join(' '),
51
- ].join(' ');
52
-
53
- console.log('execute script merge ...')
54
- console.log(cmd_merge);
55
-
56
- let exec_merge = exec(cmd_merge);
57
- exec_merge.stdout.on('data', (data) => {
58
- console.log(data);
59
- });
60
- exec_merge.stderr.on('data', (data) => {
61
- console.log('error', data);
62
- });
63
- exec_merge.stdout.on('close', (data) => {
64
- console.log(['merge finish!', videoTitle].join(' '));
65
-
66
- if (true) {
67
- console.log('remove inputFile');
68
- fs.unlinkSync(pathInputVideo);
69
- fs.unlinkSync(pathInputAudio);
70
- }
71
-
72
- console.log('rename output mkv video...');
73
- fs.renameSync(pathOutput, pathMKVOutput);
74
-
75
- if (playVideoAfterMerged) {
76
- console.log('play mkv video...');
77
- execSync('"' + pathMKVOutput + '"');
78
- }
79
-
80
- if (true) {
81
- console.log('remove script file');
82
- fs.unlinkSync(pathJsFile);
83
- }
84
- });
85
-
86
- } else {
87
- console.log('pathToMkvmerge error')
88
-
89
- }
90
- }
91
- `;
92
- }
93
-
94
- /**
95
- *
96
- * @param videoInfo
97
- * @param videoInfo.vid{string}
98
- * @param videoInfo.videoTitle{string}
99
- * @return {string}
100
- */
101
- export function generateMkvScriptForSystemFedora(videoInfo) {
102
- // We wrap the Node.js script inside a Linux Shell script block
103
- return `#!/usr/bin/env bash
104
- # This header tells Fedora to treat this file as a runnable bash script
105
-
106
- # Open a terminal window if not already running inside one
107
- if [ -z "$VTE_VERSION" ] && [ -z "$ALACRITTY_WINDOW_ID" ] && [ -z "$KITTY_WINDOW_ID" ] && [ "$1" != "--child" ]; then
108
- # Re-run this same script inside a visible terminal window so the user sees progress
109
- gnome-terminal -- "$0" --child
110
- exit 0
111
- fi
112
-
113
- # Run the embedded Node.js code below
114
- node << 'EOF'
115
- const path = require('path');
116
- const fs = require('fs');
117
- const { execSync } = require('node:child_process');
118
-
119
- let pathDownload = path.join(__dirname);
120
- let dot = '.';
121
- let extMKV = 'mkv';
122
-
123
- let {vid, videoTitle} = ${JSON.stringify(videoInfo)};
124
- let playVideoAfterMerged = true;
125
- let pathToMkvmerge = '/usr/bin/mkvmerge';
126
-
127
- let pathMKVOutput = path.join(pathDownload, videoTitle.concat(dot, extMKV));
128
- let pathOutput = path.join(pathDownload, vid.concat(dot, extMKV));
129
- let pathInputAudio = path.join(pathDownload, vid.concat(dot, "mp3"));
130
- let pathInputVideo = path.join(pathDownload, vid.concat(dot, "mp4"));
131
-
132
- if (fs.existsSync(pathToMkvmerge)) {
133
- console.log('\\nfile check ok! ' + videoTitle);
134
-
135
- let cmd_merge = [
136
- '"' + pathToMkvmerge + '"',
137
- '-o', '"' + pathOutput + '"',
138
- '--no-video', '"' + pathInputAudio + '"',
139
- '--no-audio', '"' + pathInputVideo + '"',
140
- ].join(' ');
141
-
142
- console.log('execute script merge ...\\n' + cmd_merge);
143
-
144
- try {
145
- // Run merge synchronously so stdout pipes directly to the terminal
146
- execSync(cmd_merge, { stdio: 'inherit' });
147
- console.log('merge finish! ' + videoTitle);
148
-
149
- console.log('remove inputFile');
150
- if (fs.existsSync(pathInputVideo)) fs.unlinkSync(pathInputVideo);
151
- if (fs.existsSync(pathInputAudio)) fs.unlinkSync(pathInputAudio);
152
-
153
- console.log('rename output mkv video...');
154
- fs.renameSync(pathOutput, pathMKVOutput);
155
-
156
- if (playVideoAfterMerged) {
157
- console.log('play mkv video...');
158
- // xdg-open usually hands off to the player and exits immediately
159
- execSync('xdg-open "' + pathMKVOutput + '"');
160
- }
161
- } catch (err) {
162
- console.error('An error occurred during processing:', err.message);
163
- }
164
- } else {
165
- console.log('pathToMkvmerge error. run: sudo dnf install mkvtoolnix')
166
- }
167
- EOF
168
-
169
- # Prevent the terminal window from closing instantly so the user can read messages
170
- echo ""
171
- echo "Press Enter to exit and automatically delete this script..."
172
- read unused_input
173
-
174
- # Deletes the shell script file itself after completion
175
- rm -- "$0"
176
- `;
177
- }
package/src/opStorage.js DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- *
3
- * @param k{string}
4
- * @returns {Promise<boolean>}
5
- */
6
- export async function stoOpCheck(k) {
7
- let key = k.toString();
8
-
9
- let objGet = await browser.storage.local.get(key);
10
- let b = objGet.hasOwnProperty(key);
11
- return b;
12
- }
13
-
14
- /**
15
- *
16
- * @param k{string}
17
- * @returns {Promise<any|null>}
18
- */
19
- export async function stoOpGet(k) {
20
- let key = k.toString();
21
- let objGet = await browser.storage.local.get(key);
22
- let v = objGet[key];
23
- return v;
24
- }
25
-
26
- /**
27
- *
28
- * @returns {Promise<{[p: string]: any}|null>}
29
- */
30
- export async function stoOpGetAll() {
31
- return await browser.storage.local.get();
32
- }
33
-
34
- /**
35
- *
36
- * @param k{string}
37
- * @returns {Promise<string[]|null>}
38
- */
39
- export async function stoOpQueryStartWith(k) {
40
- let objAll = await browser.storage.local.get();
41
- let keys = Object.keys(objAll);
42
- return keys.filter(value => value.startsWith(k.toString()));
43
- }
44
-
45
- /**
46
- *
47
- * @param k{string}
48
- * @param v{any}
49
- * @returns {Promise<void>}
50
- */
51
- export async function stoOpSet(k, v) {
52
- let key = k.toString();
53
-
54
- let objNew = {};
55
- objNew[key] = v;
56
- await browser.storage.local.set(objNew);
57
- }
58
-
59
- /**
60
- *
61
- * @param k{string}
62
- * @returns {Promise<void>}
63
- */
64
- export async function stoOpRem(k) {
65
- let key = k.toString();
66
- await browser.storage.local.remove(key);
67
- }
68
-
69
- /**
70
- *
71
- * @param k{string}
72
- * @returns {Promise<void>}
73
- */
74
- export async function stoOpSetNull(k) {
75
- await stoOpSet(k, null);
76
- }