-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
25 lines (25 loc) · 814 Bytes
/
background.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
chrome.contextMenus.create({
title: "Save emoticon",
contexts : ["image"],
onclick : function(content) {
if (content.srcUrl.indexOf('https://emos.plurk.com') < 0) {
return alert('Failed to save. The emot should be a custom plurk emot from emos.plurk.com');
}
try {
var key = "plurkemot_emosplurk_" + content.srcUrl.split('com/')[1].split('.')[0];
var obj = {};
obj[key] = content.srcUrl;
chrome.storage.sync.get(key, function(existing){
if (Object.keys(existing).length > 0) {
return alert('The emot is already exists');
}
chrome.storage.sync.set(obj, function(){
alert('Emot saved successfuly (dance)');
});
});
} catch(e) {
console.log(e);
alert('Failed to save the emot.');
}
}
});