1

I have to develop a chrome extension for my thesis which does following analysis:

This extension should analyse the javascript files (.js) and webssembly files (.wasm) of visited webpages. For example i have to check if a javascript file contains a special string X. In somepages included files are on visited domain in somepages on another domain. Via security reasons maybe it would be diffucult to get content of these files. Is it possible to get content of these files as a variable?

5
  • Possible duplicate of How to read file from chrome extension? Commented Feb 3, 2018 at 17:58
  • i think this is not duplicate. because i want also read content of webassembly files Commented Feb 3, 2018 at 18:02
  • Once you read the file in a var, will that not be reading the content of the file? Commented Feb 3, 2018 at 18:04
  • You can use chrome.webRequest to see what files the browser is loading and use AJAX to download the files you're interested in to do your check. Commented Feb 3, 2018 at 18:08
  • do you have maybe a sample usage for chrome.webRequest? Commented Feb 3, 2018 at 18:20

1 Answer 1

2

Get file contents with jquery

jQuery.get('http://localhost/filename.ext', function(data) { var jsFile = data; }); 
Sign up to request clarification or add additional context in comments.

3 Comments

i get following error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ***************** is therefore not allowed access. The response had HTTP status code 400.
This is a separate issue, hence a separate question ready resolved in this question stackoverflow.com/questions/20035101/…. you are reading the URL of a different domain. Look at "Using CORS."
And is there any option to get the content via chrome sources? is there any special permission for chrome extensions to read content of loaded files?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.