@vacantthinker/firefox-addon-framework-easy 2026.605.333 → 2026.605.843
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 +9 -1
- package/package.json +1 -1
- package/src/browserRuntimeOnMessageCommon.js +35 -3
package/README.md
CHANGED
|
@@ -61,7 +61,15 @@ export function browserRuntimeManifestName() { }
|
|
|
61
61
|
|
|
62
62
|
### 📄 File: `src/browserRuntimeOnMessageCommon.js`
|
|
63
63
|
```javascript
|
|
64
|
-
export function browserRuntimeOnMessageCommon(
|
|
64
|
+
export function browserRuntimeOnMessageCommon(
|
|
65
|
+
act,
|
|
66
|
+
message,
|
|
67
|
+
sendResponse
|
|
68
|
+
) { }
|
|
69
|
+
|
|
70
|
+
export function browserRuntimeOnMessageMerge(
|
|
71
|
+
message, sender
|
|
72
|
+
) { }
|
|
65
73
|
|
|
66
74
|
```
|
|
67
75
|
|
package/package.json
CHANGED
|
@@ -6,22 +6,29 @@ import {browserNotificationCreate} from './browserNotification.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* offer common act <=> function, eg: actRemoveTab, actLog
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
9
|
* @param act{
|
|
12
10
|
* 'actLog'
|
|
11
|
+
* |'actRequestTabIdTabUrl'
|
|
13
12
|
* |'actNotification'
|
|
14
13
|
* |'actRemoveTab'
|
|
15
14
|
* |'actDownloadFile'
|
|
16
15
|
* |'actSendMessageToTab'
|
|
17
16
|
* }
|
|
18
17
|
* @param message
|
|
18
|
+
* @param sendResponse
|
|
19
19
|
*/
|
|
20
|
-
export function browserRuntimeOnMessageCommon(
|
|
20
|
+
export function browserRuntimeOnMessageCommon(
|
|
21
|
+
act,
|
|
22
|
+
message,
|
|
23
|
+
sendResponse
|
|
24
|
+
) {
|
|
21
25
|
switch (act) {
|
|
22
26
|
case 'actLog':
|
|
23
27
|
console.log('act', act, 'message', message);
|
|
24
28
|
break;
|
|
29
|
+
case 'actRequestTabIdTabUrl':
|
|
30
|
+
sendResponse(message);
|
|
31
|
+
break
|
|
25
32
|
case 'actNotification':
|
|
26
33
|
browserNotificationCreate(message.content)
|
|
27
34
|
break
|
|
@@ -37,3 +44,28 @@ export function browserRuntimeOnMessageCommon(act, message) {
|
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param message
|
|
51
|
+
* @param sender
|
|
52
|
+
* @returns {
|
|
53
|
+
* 'actLog'
|
|
54
|
+
* |'actRequestTabIdTabUrl'
|
|
55
|
+
* |'actNotification'
|
|
56
|
+
* |'actRemoveTab'
|
|
57
|
+
* |'actDownloadFile'
|
|
58
|
+
* |'actSendMessageToTab'
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
export function browserRuntimeOnMessageMerge(
|
|
62
|
+
message, sender
|
|
63
|
+
) {
|
|
64
|
+
let keyAct = 'act';
|
|
65
|
+
let act = message[keyAct];
|
|
66
|
+
delete message[keyAct];
|
|
67
|
+
message['tabId'] = sender.tab?.id;
|
|
68
|
+
message['tabUrl'] = sender.tab?.url;
|
|
69
|
+
|
|
70
|
+
return act;
|
|
71
|
+
}
|