@vacantthinker/firefox-addon-framework-easy 2026.602.1003 → 2026.603.1511
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 +2 -0
- package/package.json +1 -1
- package/src/browserDownload.js +5 -1
- package/src/browserTab.js +37 -5
package/README.md
CHANGED
|
@@ -61,6 +61,8 @@ export function browserRuntimeManifestName() { }
|
|
|
61
61
|
|
|
62
62
|
### 📄 File: `src/browserTab.js`
|
|
63
63
|
```javascript
|
|
64
|
+
export async function browserTabCreateToDownload(message) { }
|
|
65
|
+
|
|
64
66
|
export async function browserTabCreateNearSendMessageToContentJs(message) { }
|
|
65
67
|
|
|
66
68
|
export function browserTabWaitReloadThenRemoveIt({ }
|
package/package.json
CHANGED
package/src/browserDownload.js
CHANGED
|
@@ -12,5 +12,9 @@ export async function browserDownloadByDownlink(
|
|
|
12
12
|
}) {
|
|
13
13
|
|
|
14
14
|
let url = downlink;
|
|
15
|
-
|
|
15
|
+
let options = {url};
|
|
16
|
+
if (filename) {
|
|
17
|
+
Object.assign(options, {filename});
|
|
18
|
+
}
|
|
19
|
+
await browser.downloads.download(options);
|
|
16
20
|
}
|
package/src/browserTab.js
CHANGED
|
@@ -8,7 +8,40 @@ async function browserTabSendMessage(tabId, message) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* must has, url
|
|
12
|
+
* @param message{{
|
|
13
|
+
* tabId:number,
|
|
14
|
+
* title:string,
|
|
15
|
+
* url:string,
|
|
16
|
+
* focusNewTab:boolean,
|
|
17
|
+
* }}
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
export async function browserTabCreateToDownload(message) {
|
|
21
|
+
let {title, url} = message;
|
|
22
|
+
await browserNotificationCreate(`new tab! ${title || url}`);
|
|
23
|
+
|
|
24
|
+
let {focusNewTab} = message;
|
|
25
|
+
let properties = {
|
|
26
|
+
url, tabId: message.tabId,
|
|
27
|
+
active: focusNewTab || false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
let {tabId} = await tabOpCreateNear(properties);
|
|
31
|
+
browser.tabs.onUpdated.addListener(
|
|
32
|
+
async function lis(tabId, changeInfo) {
|
|
33
|
+
if (changeInfo.status === 'complete') {
|
|
34
|
+
browser.tabs.onUpdated.removeListener(lis);
|
|
35
|
+
// todo code here
|
|
36
|
+
await tabOpRemove(tabId)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
, {tabId, properties: ['status']});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* must has, tabId, url
|
|
12
45
|
* @param message{{
|
|
13
46
|
* tabId:number,
|
|
14
47
|
* title:string,
|
|
@@ -19,12 +52,12 @@ async function browserTabSendMessage(tabId, message) {
|
|
|
19
52
|
*/
|
|
20
53
|
export async function browserTabCreateNearSendMessageToContentJs(message) {
|
|
21
54
|
let {title, url} = message;
|
|
22
|
-
await browserNotificationCreate(`new tab! ${title}`);
|
|
55
|
+
await browserNotificationCreate(`new tab! ${title || url}`);
|
|
23
56
|
|
|
24
57
|
let {focusNewTab} = message;
|
|
25
58
|
let properties = {
|
|
26
59
|
url, tabId: message.tabId,
|
|
27
|
-
active: focusNewTab,
|
|
60
|
+
active: focusNewTab || false,
|
|
28
61
|
};
|
|
29
62
|
|
|
30
63
|
let {tabId} = await tabOpCreateNear(properties);
|
|
@@ -38,11 +71,10 @@ export async function browserTabCreateNearSendMessageToContentJs(message) {
|
|
|
38
71
|
}
|
|
39
72
|
}
|
|
40
73
|
, {tabId, properties: ['status']});
|
|
41
|
-
|
|
42
74
|
}
|
|
43
75
|
|
|
44
76
|
/**
|
|
45
|
-
*
|
|
77
|
+
* tab exists, watch it, reload then close
|
|
46
78
|
* @param param0
|
|
47
79
|
* @param param0.tabId{number}
|
|
48
80
|
*/
|