forked from MrXujiang/fetchImg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
30 lines (27 loc) · 909 Bytes
/
popup.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
chrome.storage.sync.get('imgArr', function(data) {
data.imgArr && data.imgArr.forEach(item => {
var imgWrap = $("<div class='img-box'></div>")
var img = $("<img src='" + item + "' alt='" + item + "' />")
imgWrap.append(img);
$('#content').append(imgWrap);
$('.empty').hide();
})
});
$('#activeBtn').click(function(element) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, "activeBtn", function(response) {
console.log(response);
});
});
});
// $('#pop').on("click",
// function() {
// window.postMessage({ type: "FROM_PAGE", text: "Hello from the webpage!" }, "*");
// }, false);
// $('#go-to-options').on('click',function() {
// if (chrome.runtime.openOptionsPage) {
// chrome.runtime.openOptionsPage();
// } else {
// window.open(chrome.runtime.getURL('options.html'));
// }
// });