-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
49 lines (45 loc) · 1.78 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
chrome.runtime.setUninstallURL("https://1ce.org");
if (!localStorage.created) {
chrome.tabs.create({ url: "https://1ce.org" });
var manifest = chrome.runtime.getManifest();
localStorage.ver = manifest.version;
localStorage.created = 1;
}
//console.log(chrome.browserAction.onClicked);
chrome.browserAction.onClicked.addListener(function(tab){
//console.log('clicke');
chrome.tabs.query({'active': true},function(curTabs){
//console.log(curTabs)
if(curTabs[0] && curTabs[0] && curTabs[0].id){
//console.log(curTabs[0].id, img);
//chrome.tabs.sendMessage(curTabs[0].id, {action:'showCover'});
chrome.tabs.executeScript(null, {file: "js/picker.js"});
chrome.tabs.insertCSS(null, {file: "css/picker.css"});
}
});
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
//console.log(request,sender);
switch(request.action){
case 'colorPicked':
chrome.tabs.captureVisibleTab(null,{format:'png'}, function(img){
chrome.tabs.sendMessage(sender.tab.id,{action:'ctx'/*,data:pixelData*/,image:img,data:request.data});
setTimeout(injectJsCurrentTab,3000);
//};
// image.width = (request.data.width /request.data.innerOuterRatioWidth);
// image.height = (request.data.width /request.data.innerOuterRatioWidth);
// image.src = img;
})
break;
// case 'popupstarted':
// chrome.tabs.query({'active': true},function(curTabs){
// //console.log(curTabs)
// if(curTabs[0] && curTabs[0] && curTabs[0].id){
// //console.log(sender);
// chrome.tabs.sendMessage(curTabs[0].id, {action:'colorPicked'});
// }
// });
// break;
}
});