@vacantthinker/firefox-addon-framework-easy 2026.526.1059 → 2026.526.1124

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/README.md CHANGED
@@ -25,7 +25,10 @@ export class BaseORM { }
25
25
 
26
26
  ### 📄 File: `src/browserNotification.js`
27
27
  ```javascript
28
- export async function browserNotificationCreate(content, title = null) { }
28
+ export async function browserNotificationCreate(
29
+ content,
30
+ title = browserRuntimeManifestName()
31
+ ) { }
29
32
 
30
33
  ```
31
34
 
@@ -140,7 +143,7 @@ export function serviceGetCurrentDateYYYYMMDDHHMMSS() { }
140
143
 
141
144
  ### 📄 File: `src/serviceOpContent.js`
142
145
  ```javascript
143
- export function serviceCopyContentToClipboard(content) { }
146
+ export async function serviceCopyContentToClipboard(data) { }
144
147
 
145
148
  export function serviceSaveContentToLocal(content, filename, ext = 'txt') { }
146
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy",
3
- "version": "2026.0526.1059",
3
+ "version": "2026.0526.1124",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -1,19 +1,24 @@
1
+ import {browserRuntimeManifestName} from './browserRuntime.js';
2
+
1
3
  /**
2
4
  *
3
- * @param { string}content
4
- * @param {string|null}title
5
+ * @param content{ string}
6
+ * @param title{string}
5
7
  * @returns {Promise<string>}
6
8
  */
7
- export async function browserNotificationCreate(content, title = null) {
9
+ export async function browserNotificationCreate(
10
+ content,
11
+ title = browserRuntimeManifestName()
12
+ ) {
13
+
8
14
  const tag = 'browserNotificationCreate';
9
15
  try {
10
16
  let notificationId = `${tag}cake-noti`;
11
- title = title ? title : browser.runtime.getManifest().name;
12
17
  console.info(tag, `content=${content}`, `title=${title}`);
13
18
  await browser.notifications.create(notificationId, {
14
19
  type: 'basic',
15
20
  title,
16
- message: content,
21
+ message: `${content}`,
17
22
  });
18
23
  return notificationId;
19
24
  } catch (e) {
@@ -269,23 +269,25 @@ export async function serviceDealWithMagnetLink(message) {
269
269
 
270
270
  let {title, data, handleOption} = message;
271
271
  let titleCleaned = serviceRemoveIllegalWord(title);
272
- console.info('content.length', data.length);
272
+ console.info(`data.length=\n`, data.length);
273
273
 
274
274
  if (Array.isArray(data) && data.length >= 1) {
275
275
  let content = `${data.join('\n')}\n`;
276
+ console.info(`content=\n`, content);
277
+
276
278
  let filename = [
277
279
  'magnet-link',
278
280
  titleCleaned,
279
281
  serviceGetCurrentDateYYYYMMDDHHMMSS()].join(' ');
280
282
 
281
283
  if (handleOption === 'clipboard') {
282
- serviceCopyContentToClipboard(content);
284
+ await serviceCopyContentToClipboard(content);
283
285
  }
284
286
  else if (handleOption === 'txt') {
285
287
  serviceSaveContentToLocal(content, filename);
286
288
  }
287
289
  else if (handleOption === 'clipboardAndTxt') {
288
- serviceCopyContentToClipboard(content);
290
+ await serviceCopyContentToClipboard(content);
289
291
  serviceSaveContentToLocal(content, filename);
290
292
  }
291
293
  }
@@ -1,17 +1,17 @@
1
-
2
1
  /**
3
2
  *
4
- * @param{string} content
3
+ * @param data
4
+ * @returns {Promise<void>}
5
5
  */
6
- export function serviceCopyContentToClipboard(content) {
7
- window.navigator.clipboard.writeText(content).then(r => null);
6
+ export async function serviceCopyContentToClipboard(data) {
7
+ return await window.navigator.clipboard.writeText(data);
8
8
  }
9
9
 
10
10
  /**
11
11
  * eg: fnName('this is content', 'this is a filename without ext', 'txt')
12
12
  * @param {string} content
13
13
  * @param {string} filename eg: abc
14
- * @param {string} ext txt json cmd js ...
14
+ * @param {string} ext txt json
15
15
  */
16
16
  export function serviceSaveContentToLocal(content, filename, ext = 'txt') {
17
17
  const eleBtn = document.createElement('button');
@@ -19,8 +19,12 @@ export function serviceSaveContentToLocal(content, filename, ext = 'txt') {
19
19
  'click',
20
20
  function() {
21
21
  const eleA = document.createElement('a');
22
- let type = 'text/plain';
23
- // let type = 'application/json';
22
+
23
+ const extObj = {
24
+ txt: 'text/plain',
25
+ json: 'application/json'
26
+ }
27
+ const type = extObj[ext];
24
28
 
25
29
  const file = new Blob([content], {type});
26
30
  eleA.href = URL.createObjectURL(file);