What do I need to change here so that the JavaScript code works with the manifest version 2 and the security policy?
Screenshot:
Code:
function init()
{
chrome.tabs.getSelected(null, function(tab)
{
url = tab.url;
if(url.indexOf('chrome://') == -1 && url.indexOf('about:blank') == -1){
document.main.q.value = url;
}
});
}
I got it working after I put the JavaScript code from the HTML file into an own file and added the following to the manifest file:
"content_scripts": [ {"js": [ "popup.html" ], "matches": [ "http://*/" ]} ],
"permissions": [ "tabs" ]
The inline event handler definition must be rewritten in terms of addEventListener
and extracted into popup.js
, so you should remove the onfocus="this.select()"
in your popup.html
, and in the popup.js
, add the following lines:
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('address_box').addEventListener('onfocus', this.select);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With