1 //file which parses document body
3 // is prototype insane?
5 delete Array.prototype.toJSON;
6 delete Object.prototype.toJSON;
8 delete Hash.prototype.toJSON;
9 delete String.prototype.toJSON;
15 gatherlinks : function () {
17 for (var i= document.links.length; i-->0;){
19 href: document.links[i].href,
20 label : document.links[i].textContent
24 console.log(JSON.stringify( {
25 requesturl : document.location.href, // buggy - we should return the requested path.
26 method: 'gatherlinks' ,
33 downloadhead : function (url) {
34 var xmlhttp = new XMLHttpRequest();
37 xmlhttp.open("HEAD", url,true);
38 xmlhttp.onreadystatechange=function() {
39 if (xmlhttp.readyState==4) {
43 method: 'downloadhead',
44 headers : xmlhttp.getAllResponseHeaders(),
45 contentType:xmlhttp.getResponseHeader("Content-Type"),
55 downloadpage : function (url) {
58 var xmlhttp = new XMLHttpRequest();
60 xmlhttp.open("GET", url,true);
61 xmlhttp.responseType = 'arraybuffer';
63 xmlhttp.onload=function() {
67 var r = new Uint8Array(xmlhttp.response);
68 for (i=0;i<r.byteLength;i++) {
75 method: 'downloadpage',
76 headers : xmlhttp.getAllResponseHeaders(),
77 contentType:xmlhttp.getResponseHeader("Content-Type"),