0

I'm developing a chrome extension that needs to save the current loaded page(.js and .html) and then generate a SHA1 hash of that loaded page. I have read everywhere that chrome extension doesn't allow loading a file which doesn't belong to its extension directory and is required to use NPAPI.

So I need some advice on what could be the best way for me to accomplish this?

Any help is greatly appreciated!

Onion
  • 13
  • 3

1 Answers1

0

One way you could achieve this would be to have your background page call your content script that returns the items you need, returning the following to your background page:

document.documentElement.innerHTML for the HTML

document.scripts[].innerHTML for the scripts

If you have external javascript then re-request the js file by XMLHttpRequest in your background page. Otherwise if the script is inline then you can simply just hash that.

Once you have all the files you can easily perform your hash and then save the file. As this article suggests either the POST/GET or better HTML5 local storage: Chrome extension: How to save a file on disk

This is a good article that shows how to get the communication going: http://markashleybell.com/building-a-simple-google-chrome-extension.html

Community
  • 1
  • 1
RidingTheRails
  • 1,105
  • 1
  • 12
  • 22