As described in the documentation , you cannot use the chrome.* API in content scripts, with the exception of some chrome.extension.* Methods.
However, this does not limit you, as you can use messaging to call your script content from your background page. For instance:
background.html
<script type="application/javascript"> chrome.browserAction.onClicked.addListener(function() { chrome.tabs.getSelected(function (tab) { chrome.tabs.sendRequest(tab.id, {title: 'new page title'}, function (response) {}); }); }); </script>
changetitle.js
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) { document.title = request.title; });
To use this technique, you will of course need tabs permission.
source share