Home » Javascript » How to Copy HTML of Active Page in Chrome Extension?

How to Copy HTML of Active Page in Chrome Extension?

Posted by: admin June 30, 2018 Leave a comment

Questions:

I am making a google chrome extension, in that app I want to copy the HTML of third party website for content scraping purposes. I am using following JQuery function for this,

$(".abc").clone().html();

It works good in simple HTML page, but doesn’t when I use it in the popup.js file of the extension.

How can I copy the HTML of the webpage in Chrome Extension?

My manifest.json file is

{
  // Required
  "manifest_version": 2,
  "name": "WGCE",
  "version": "1.0",
  // Recommended
  "description": "App Description",
  // Pick one (or none)
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [
    "cookies",
    "tabs",
    "http://*/*",
    "https://*/*"
  ],
  "content_scripts": [{
    "js": ["popup.js"],
    "matches": ["https://example.com/*"]
  }]
}
Answers: