iagdotme

Yahoo2CSV Bookmarklet

Oct 12th, 2012
3,658
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(){function toCSV(rows){var newline='\n';var fsep=',';var quot='"';var quotquot=[quot+quot,'\\'+quot][1];var alwaysQuote=false;var quoteIfContainsQuote=true;var lines=[];$.each(rows,function(){var line=[];$.each(this,function(){var s=this;var needsQuote=alwaysQuote;if(s.indexOf(fsep)>=0)needsQuote=true;if(s.indexOf(quot)>=0){needsQuote=needsQuote || quoteIfContainsQuote;s=s.replace(quot,quotquot);}if(needsQuote)s=quot+s+quot;line.push(s);});lines.push(line.join(fsep));});return lines.join(newline);}function xtract(rootTableSelector){var rows=[];var csv=[];csv.push(['Name','Email']);$(rootTableSelector).each(function(){var $t=$(this);var row={};row.name=$.trim($t.find('tr:nth-child(1) > td > b').text());row.email=$.trim($t.find('tr:nth-child(2) > td > div:nth-child(2)').text());rows.push(row);csv.push([row.name,row.email]);});csv=toCSV(csv);$('<textarea/>').text(csv).css({position:'fixed',width:'80%25',height:'80%25',top:'10%25',left:'10%25'}).appendTo('body').focus().select();}var s=document.createElement('script');s.setAttribute('src','http://code.jquery.com/jquery.min.js');s.setAttribute('type','text/javascript');document.getElementsByTagName('body')[0].appendChild(s);function f(){var $=window.jQuery;if(!$){setTimeout(f,100);return;}$(function(){xtract('.qprintable2');});}f();})();
RAW Paste Data