Background.js:
chrome.tabs.executeScript(tab.id,
{
file: "exec_script.js"
}, function(res) {
console.log(res);
});
exec_script.js:
var test = html2canvas(document.body, {
allowTaint: false,
letterRendering: true,
logging: true
}).then(function (canvas) {
var dataUrl = canvas.toDataURL();
var bImage = dataUrl.replace('data:image/png;base64,', '');
});
test
As far as I know, the last statement in exec_script.js have to be passed to the callback as the result parameter. But it returns empty object.
But if I make as following in exec_script.js:
var test = "good";
test
It returns a value of the variable to the callback.
Also the tab is not focused.
resis a plain object? What value are you expecting to be passed to callback?returnbImagefrom.then()chained tohtml2canvascall, chaining.then()toresat callback?chrome.tabs.executeScriptdoesn't block the extension process until the code in the tab has finished.testdoes not referencebImagevalue.testis aPromise,.then()is used to getPromisevalue.