Skip to content

Instantly share code, notes, and snippets.

@frah
Last active December 19, 2015 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frah/6016248 to your computer and use it in GitHub Desktop.
Save frah/6016248 to your computer and use it in GitHub Desktop.
javascript:(function(){var o=function(w,v){var i=new Blob([v]);var u=window.URL||window.webkitURL;var t=u.createObjectURL(i);var e=document.createElement("a");e.download=w;e.href=t;return e};var c=function(a){return unescape(escape(a).replace(/(%u3000|%20|%09)/g,""))};var r=document.getElementsByTagName("table")[10].innerText.trim();var d=document.getElementsByTagName("table")[11];var j=d.getElementsByTagName("tr");var s="";var n="";var h="";for(var g=0;g<j.length;g++){var l=j[g];if(l.attributes.length==0){var q=o("address.csv",n);q.innerText="[CSV Download]";l.children[0].insertBefore(q,l.children[0].firstChild);s=s+n;n="";continue}if(l.attributes[0].value=="#B0C4DE"){h=l.children[0].innerText}else{var p=l.children[1].innerText;var m=c(p.substring(0,3));p=c(p.substring(3));var f=m+","+p+","+m+" "+p;f+=","+r+","+h+",";f+=l.children[0].innerText.replace(/[A-Za-z0-9]/g,function(a){return String.fromCharCode(a.charCodeAt(0)-65248)});f+=","+l.children[2].innerText.replace(/\n/g,"");f+=","+c(l.children[3].innerText);f+="\n";n+=f}}var k=document.createElement("tr");var q=o("address.csv",n);q.innerText="[CSV Download]";var b=document.createElement("td");b.setAttribute("colspan","5");b.appendChild(q);k.appendChild(b);d.children[0].appendChild(k);s+=n;k=document.createElement("tr");q=o("DeptAddress.csv",s);q.innerText="[Dept CSV Download]";b=document.createElement("td");b.setAttribute("colspan","5");b.appendChild(q);k.appendChild(b);d.children[0].appendChild(k)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment