1

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!

2 Answers2

2

Works fine on my browser

Reload the extension.

if it still does not work, sign out of Google Chrome and sign in again.

  • Thanks reloading the extension and re-starting chrome worked. Strange. –  Apr 01 '13 at 10:24
0

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.

pexeer
  • 685
  • 5
  • 8
  • Thanks for the response, it works in my friend's browser too, but not on mine!!! Do you happen to know why? –  Mar 28 '13 at 06:29