-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathbackground.js
More file actions
41 lines (36 loc) · 1.03 KB
/
Copy pathbackground.js
File metadata and controls
41 lines (36 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
41
function handleMessage(request) {
if (
request &&
request.closeWebPage === true &&
request.isSuccess === true
) {
/* Set username */
chrome.storage.local.set({
leethub_username: request.username,
});
/* Set token */
chrome.storage.local.set({ leethub_token: request.token });
/* Close pipe */
chrome.storage.local.set({ pipe_leethub: false }, () => {
console.log('Closed pipe.');
});
chrome.tabs.getSelected(null, function (tab) {
chrome.tabs.remove(tab.id);
});
/* Go to onboarding for UX */
const urlOnboarding = chrome.runtime.getURL('welcome.html');
chrome.tabs.create({ url: urlOnboarding, active: true });
} else if (
request &&
request.closeWebPage === true &&
request.isSuccess === false
) {
alert(
'Something went wrong while trying to authenticate your profile!',
);
chrome.tabs.getSelected(null, function (tab) {
chrome.tabs.remove(tab.id);
});
}
}
chrome.runtime.onMessage.addListener(handleMessage);