-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
27 lines (21 loc) · 806 Bytes
/
content.js
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
// Setup listener for event sent by the injected script
window.addEventListener('x-user', event => {
const payload = event.detail;
// Check if the user is logged-in
if (payload.id === null) {
return;
}
(async() => {
const module = await import (chrome.runtime.getURL('./content/bootstrap.js'));
const bootstrap = module.default;
const app = await bootstrap(payload.id);
window.addEventListener('x-popup', event => {
app.enhancePopup(event.detail.id);
});
})();
});
// Inject script to retrieve the logged-in user's ID
const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', chrome.extension.getURL('inject.js'));
document.body.appendChild(script);