I would like, when I clicked the extension button, I wrote in the console the title
of the page.
My current code is this:
background.js
chrome.browserAction.onClicked.addListener(function() {
chrome.tabs.executeScript(null, {
code: 'console.log(document.getElementsByTagName("title")[0].innerText);'
});
});
manifest.json
{
"name": "log print",
"description": "usar console.log()",
"version": "1",
"permissions":[
"tabs",
"activeTab",
"https://*/*",
"http://*/*"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"background": {
"persistent": true,
"scripts": ["background.js"]
},
"browser_action": {
"default_title": "Teste",
"default_popup": "popup.html"
},
"manifest_version": 2
}
popup.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button id="Mr_Button">hello this is a test</button>
</body>
</html>