-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
28 lines (25 loc) · 862 Bytes
/
background.js
File metadata and controls
28 lines (25 loc) · 862 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
try {
importScripts('igim/lib/instagram.js', 'igim/lib/notification.js');
} catch (e) {
console.error("err importScripts: ", e);
}
const igClient = InstagramAPI.new();
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if(request.action === 'getUnfollowers'){
igClient.unfollowers().then(resp => {
// No error handling rightNow.
chrome.storage.local.set({unfollowers: JSON.stringify(resp)}, () => {
createNotification("Request Done", "unfollowers list ready")
chrome.action.setBadgeText({text: "1"})
chrome.action.setBadgeBackgroundColor({color: "red"})
sendResponse(resp)
})
})
}
if(request.action === 'unfollowersCache'){
chrome.storage.local.get(['unfollowers'], result => {
sendResponse(JSON.parse(result.unfollowers) || [])
})
}
return true
});