forked from quoid/userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnative.js
More file actions
29 lines (25 loc) · 816 Bytes
/
Copy pathnative.js
File metadata and controls
29 lines (25 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void
delete
end
stop
close
/**
* @see {@link https://vitejs.dev/guide/env-and-mode.html}
* @returns {string}
*/
const application = () => import.meta.env.NATIVE_APP ?? "application";
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/connectNative}
* @returns {import("webextension-polyfill").Runtime.Port} A `runtime.Port` object
*/
export function connectNative() {
return browser.runtime.connectNative(application());
}
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage}
* @param {any} message
* @returns {Promise<any>} A response of JSON object or no arguments
*/
export function sendNativeMessage(message) {
return browser.runtime.sendNativeMessage(application(), message);
}