-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (29 loc) · 900 Bytes
/
main.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
28
29
30
31
32
33
34
35
36
37
var imageSelected;
var imageClicked = function (info) {
var uploadImage;
uploadImage = info.srcUrl ? info.srcUrl : imageSelected;
console.log(uploadImage);
if(uploadImage) {
$.ajax({
url: "https://api.imgur.com/3/image",
headers: {
'Authorization': 'Client-ID 2fd973a2668bfcf'
},
type: "POST",
data: {
image: uploadImage
},
success: function (data) {
console.log(data);
imageSelected = null;
chrome.tabs.create({url: data.data.link});
}
});
}
};
chrome.contextMenus.create({title: "Upload to Imgur", contexts: ["all"], onclick: imageClicked}, function () {
});
chrome.runtime.onMessage.addListener(function (message) {
console.log(message);
imageSelected = message;
});