{"size": 1207, "ext": "js", "max_stars_repo_path": "content.js", "max_stars_repo_name": "nimisha-yadav/Alexa-Init", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content.js", "max_issues_repo_name": "nimisha-yadav/Alexa-Init", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content.js", "max_forks_repo_name": "nimisha-yadav/Alexa-Init", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.7735849057, "max_line_length": 81, "alphanum_fraction": 0.676056338}
var fileNames = ""
var fileContents = ""
console.log("content.js loaded on " + document.URL)
var currentNum= 0
var text = ""
window.addEventListener("DOMContentLoaded", function(event){
	
	for( var i= 0 ; i < event.target.scripts.length;i++){

		ev = event.target.scripts[i];
		src= ev.src;
		var data = {
			"src":src, 
			"text":ev.innerText};
		text = data.text
		chrome.runtime.sendMessage({fileName: data.src})
		//name = data.src
		//downloadFileFromText(name, text)
		

	}

	

});

setTimeout(function() {
	chrome.runtime.sendMessage({nextPage: true});
},10000)

chrome.runtime.onMessage.addListener( function(request, sender, sendResponse){
		
	if (request.fileName != undefined)
		downloadFileFromText(request.currentNum + "_" + request.fileName, text)
}); 

function downloadFileFromText(filename, content) {
    var a = document.createElement('a');
    var blob = new Blob([ content ], {type : "text/plain;charset=UTF-8"});
    a.href = window.URL.createObjectURL(blob);
    a.download = filename;
    a.style.display = 'none';
    document.body.appendChild(a);
    a.click(); //this is probably the key - simulating a click on a download link
    delete a;// we don't need this anymore
} 






