-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpopup.js
21 lines (19 loc) · 799 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.addEventListener("DOMContentLoaded", async function (e) {
document.querySelectorAll('[data-i18n]').forEach(e => {
e.innerHTML = chrome.i18n.getMessage(e.dataset.i18n);
});
document.getElementById("option").addEventListener("click", function (e) {
chrome.runtime.openOptionsPage();
});
try {
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
const code = await chrome.tabs.sendMessage(tab.id, {
"functiontoInvoke": "onClick"
});
await navigator.clipboard.writeText(code);
document.getElementById("message").textContent = chrome.i18n.getMessage("copied");
} catch (e) {
document.getElementById("message").textContent = e;
console.error(e);
}
});