I am developing a small chrome extension to help my grandpa print images easily through a button in the context menu. I got to the point that the image opens on a seperate tab, after debugging I found out that "window.print()" got triggered but nothing happend.
My background.js file:
var printEnable = false;
chrome.contextMenus.create({
"title": "Print",
"type": "normal",
"contexts": ["image"],
"onclick": function(info) {
chrome.tabs.create({url: info.srcUrl});
this.printEnable = true;
}
});
chrome.tabs.onUpdated.addListener(function(){
if(printEnable){
window.print();
this.printEnable = false;
}
});
My manifest.json
{
"name": "Print",
"description": "Easy picture print",
"permissions": [ "contextMenus","tabs"],
"version": "0.1",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
},
"icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}
Can someone please help me find whats wrong with my code?