Skip to content

Instantly share code, notes, and snippets.

@amerberg
Last active July 25, 2016 02:15
Show Gist options
  • Save amerberg/6ab58f6bd093ca198405 to your computer and use it in GitHub Desktop.
Save amerberg/6ab58f6bd093ca198405 to your computer and use it in GitHub Desktop.
Quora bookmarklets
/* These are bookmarks for making various tasks on Quora easier.
* Since GitHub Markdown doesn't allow JavaScript links, you'll have to install the complicated way.
* Each of the lines beginning with `javascript:` below is a bookmarklet.
* To install, create a new bookmark in your browser and paste that line as the URL.
* Leave feedback in Gist comments or contact https://www.quora.com/Adam-Merberg
*/
//Get the rank of the answer belonging to the logged-in user (in a JS alert box).
//You will have to scroll down far enough that your answer has loaded before you use it.
//Perhaps a future version will do that automatically.
javascript:(function(){hr = $(".SiteHeaderNavItem.MoreNavItem .hover_menu_item:contains('Profile')").attr("href"); alert($(".author_info > .feed_item_answer_user>span>.user[href='"+hr+"']").parents(".pagedlist_item").index()+1)})();
/*Get the rank, word count, number of upvotes, and number of followers for all answers visible on a question page.
*Notes:
* - You need to scroll down so that all answers are loaded.
* - For numbers (upvotes/followers) > 999, only the rounded values are shown, e.g. 3.7k.
* - Follower numbers are taken from the little popup cards, which need to be loaded from Quora when you run the bookmarklet.
* Since communication with Quora is handled by Quora's scripts, I just wait 100ms per answer and hope that this is enough.
* That means it could be slow to run with lots of answers. And if your connection is slow, you might end up with follower
* information missing for some answers (reported as 0). In that case, you can just run it again, and everything
* should be fine.
* - Data appears in a textarea in a popup. You need to enable popups for this to work.
* - Data are tab separated and may look weird, but should paste nicely into any spreadsheet software.
* - This will probably break the next time Quora changes its interface.
*/
javascript:(function(){s=$(".grid_page_wrap .AnswerHeader > .feed_item_answer_user>span>.user,.grid_page_wrap .AnswerHeader > .feed_item_answer_user>span>.anon_user");s.each(function(ind, e){$(e).mouseover()});o=["Name","Rank","Word Count","Upvotes", "Views", "Followers"].join("\t")+"\n";setTimeout(function(){s.each(function(i, e){a=$(e).parents(".Answer");hr=$(e).attr("href");n=$(e).text();f=$(".ObjectCard-header .user[href='"+hr+"']").parents(".ObjectCard").find(".ObjectCard-footer .Button .count").first().text();u=a.find(".Upvote .count").text();v=a.find(".CredibilityFact").text().split(" ")[0];if(!v) v=0; if(!f) f=0;if(!u)u=0;t=a.find(".inline_editor_value");t.find("br").replaceWith("<br> ");c=t.text().split(/\s+/).filter(Boolean).length;o+=[n,i+1,c,u,v,f].join("\t")+"\n";});w=open("","as"+Math.random(),"toolbar=no,width=700,height=350");w.document.write("<textarea rows='15' cols='80'>"+o+"</textarea>");$("textarea",w.document).select();},100*s.length);})()
//That's all for now...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment