Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9143407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:01:03+00:00 2026-06-17T10:01:03+00:00

I am currently developing a Chrome extension in which I have to get the

  • 0

I am currently developing a Chrome extension in which I have to get the HTML source of a page. I currently use Chrome Messaging. Here is my source code :

background.js

chrome.webNavigation.onComplete.addListener(function(e) {
        chrome.tabs.sendRequest(e.tabId, {
            action: 'getSource'
        }, function(r) {
            console.log(r);
        });
});

contentscript.js

chrome.extension.onRequest.addListener(function(request, sender, callback) {
    if (request.action == 'getSource')
        callback(document.documentElement.outerHTML);
});

It’s pretty slow because I have to wait that every data (like image, javascript, etc.) in the page have been downloaded to get the source of the page.

Is it another way to make something like that ? Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:01:05+00:00Added an answer on June 17, 2026 at 10:01 am

    Move the wait logic to your manifest:
    → Set the run_at property of your content script in your manifest file to document_end.

    This will run the content script after the DOM was loaded but before any subresources (e.g. images) are loaded.

    In the case of “document_end”, the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded.

    — Google documentation

    In your contentscript, send the HTML directly the your background script:

    var html = document.documentElement.outerHTML;
    chrome.extension.sendMessage(null, html);
    

    But note that injected JavaScript in the page could modify the HTML thus you can end up with different HTML than you’ve got in your browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a private framework for use on WebKit devices. I have
I'm developing an extension in Chrome 4 (currently 4.0.249.0) that will show the user's
I'm developing a Google Chrome extension that makes heavy use of the context menu,
I'm currently developping a Chrome extension (which means that I don't need a cross
I'm currently developing a simple javascript extension for Chrome. The problem is simple but
I'm developing a Chrome Extension with HTML desktop notifications, but when they show up,
we're currently developing an application that makes extensive use of popup windows(*) and have
I'm currently developing a toolbar for chrome and i have some issues with my
I am currently developing a site which requires a print option on the page.
I'm currently developing a e-commerce site which is going to have around 500 items.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.