Reputation:
I'm trying to get the innerText
of the current opened tab in a chrome extension.
Here's my manifest.json:
{
"manifest_version": 2,
"name": "meow",
"description": "meow-meow-meow",
"version": "1.0",
"browser_action": {
"default_icon": "icon2.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentscript.js"]
}
],
"permissions": [
"http://*/*",
"https://*/*",
"contextMenus",
"tabs"
]
}
Here's my contentscript.js:
function getText(){
return document.body.innerText
}
console.log(getText());
But it isn't logging anything on the console! What am I missing?
EDIT: Is there a better way to get the HTML content from the current tab?
UPDATED EDIT:
This runs fine on my friend's chrome, but not on mine, both Chrome versions are 26.
Thank you!
Upvotes: 1
Views: 1866
Reputation:
Reload the extension.
if it still does not work, sign out of Google Chrome and sign in again.
Upvotes: 2
Reputation: 695
it works in my chrome browser.
open the url chrome://extensions/
, load the plugin directory.
and make sure it load correctly, and mark it enable.
Upvotes: 0