0
I would like when I click on the extension button to write on 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>