Porting HTML validator extension to WebExtension

Marc Gueury mgueury at skynet.be
Tue Sep 5 20:07:18 UTC 2017


To make this more real. Here are snippets of the code that works in Chrome.
But both with the same problems.
- It is with a debug window opened (not too important)
- But mostly, it does not work for the current page.

Nasty question :-) I know.

Thanks,

Marc

A)  With chrome.debugger
      Doc : 
https://stackoverflow.com/questions/18534771/chrome-extension-how-to-get-http-response-body 


   if (message == "Network.responseReceived") { //response return
      chrome.debugger.sendCommand({
          tabId: debuggeeId.tabId
      }, "Network.getResponseBody", {
           "requestId": params.requestId
      }, function(response) {
          console.log( "xxx "+ response.body );
      });
   }

B) With devtools.network.getHar
     Doc : https://developers.chrome.com/extensions/devtools_network

     chrome.devtools.network.getHAR(function(result) {
       var h;
       console.log("<updateHtmlReport>getHAR: " + result.entries.size);
       result.entries.forEach(function(harEntry) {
         console.log("<updateHtmlReport>loop size: " + 
harEntry.response.content.size);
         if (harEntry.response.content.size > 0 && 
harEntry.response.content.mimeType === 'text/html') {
           console.log("<updateHtmlReport>loop size: " + 
harEntry.response.content.size);
           //look for the first HTML page in the entries
           if (h === undefined) {
             h = harEntry;
           }
         }
       });
...
      if (h === undefined) {
...
      } else {
         h.getContent(function(body) {

On 05/09/2017 16:42, Marc Gueury wrote:
>
> Hi all,
>
> I am currently stuck when trying to rewrite my extension. It is nearly 
> done. But I miss APIs.
> I am not able to get the HTML of the current page sent by the server 
> from any action.
>
> I tried with more functions available on Chrome a
> a) with devtools.network and the HAR format in the dev panel
> b) chrome.debugger / Network.getResponseBody
>
> But,
> - a and b works in Chrome but only when devtools or a debug page is 
> opened.
> - And only for the request after the debugger is started
>
> But it is too late for me. I would like to get the HTML of the current 
> page.
>
> /In Firefox,//
> //N//or a) Nor b) nor what I really need seems to be available on 
> Firefox :-(/
>
> Thanks,
>
> Marc
>
>
>
> _______________________________________________
> Webextensions-support mailing list
> Webextensions-support at mozilla.org
> https://mail.mozilla.org/listinfo/webextensions-support


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/webextensions-support/attachments/20170905/eb3fe769/attachment.html>


More information about the Webextensions-support mailing list