forked from Dmitry1987/vault-chrome-extension
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcommon.js
More file actions
31 lines (28 loc) · 804 Bytes
/
common.js
File metadata and controls
31 lines (28 loc) · 804 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
30
31
/* eslint-disable no-unused-vars */
function storePathComponents(storePath) {
let path = 'secret/vaultPass';
if (storePath && storePath.length > 0) {
path = storePath;
}
const pathComponents = path.split('/');
const storeRoot = pathComponents[0];
const storeSubPath =
pathComponents.length > 0 ? pathComponents.slice(1).join('/') : '';
return {
root: storeRoot,
subPath: storeSubPath,
};
}
async function copyStringToClipboard(string) {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) {
const tab = tabs[tabIndex];
if (tab.url) {
browser.tabs.sendMessage(tab.id, {
message: 'copy_to_clipboard',
string: string,
});
break;
}
}
}