Last active
August 29, 2015 14:24
-
-
Save RadGH/fb0e45db83e6596f5650 to your computer and use it in GitHub Desktop.
GTA5 Social Club Rating Bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){var ratingToInt=function(t){t=t.trim();var e=parseFloat(t),i=t.replace(/[^kmb]/g,"");switch(i){case"k":e=1e3*e;break;case"m":e=1e6*e}return parseInt(e)},ratingsGetValues=function(t){var e=t.children("li");if(e.length<3)return!1;var i={up:ratingToInt(e.eq(0).text()),down:ratingToInt(e.eq(1).text()),play:ratingToInt(e.eq(2).text())};return i.rating=(i.up-i.down)/i.up,i},updateList=function(){var t=jQuery("#search-results-list"),e=t.find("tr.mission-result-text");e.each(function(){var t=jQuery(this),i=t.find("ul.ratings");if(!(i.find("li.percent").length>0)){var a=ratingsGetValues(i);if(!a)return void e.css("opacity","0.5");var s=Math.round(100*a.rating),r=jQuery('<li class="percent"><i class="gtavicon-icon_star"></i> '+s+"%</li>");i.append(r),i.css("margin-right",0),i.find("li").css({"margin-left":"5px","padding-left":"5px"});var n="#ffffff";n=s>90?"#ffffff":s>80?"#7EF654":s>70?"#7EF654":s>50?"#D6E647":s>40?"#DEBC41":s>25?"#D6833B":s>10?"#cc631B":"#aa0000",r.css({color:n,"padding-right":"10px"})}})},queueUpdateList=function(){updateList(),setTimeout(updateList,1e3),setTimeout(updateList,3e3),setTimeout(updateList,5e3),setTimeout(updateList,1e4),setTimeout(updateList,2e4),setTimeout(updateList,3e4),setTimeout(updateList,4e4)};jQuery(".search-previous, search-next").on("click",queueUpdateList),jQuery("#searchFrm").on("submit",queueUpdateList),updateList();}); |
HOW TO USE:
- Copy the code above, which must start with javascript:
- Create a new bookmark
- Enter a name for it, like "GTA5"
- Paste the code into the URL field
- Go to social club, GTA5 map browser
- Make sure it is on list view (http://i.imgur.com/XjN9LgJ.jpg)
- Click the bookmark
Before: http://i.imgur.com/8qIw6C0.jpg
After: http://i.imgur.com/4QL7mIS.jpg
Note: Bookmarklets can be dangerous and are often used for XSS attacks. You are literally injecting someone else's javascript code into another website. My code is not intended to be malicious in any way, but use at your own risk.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full version available here: https://gist.github.com/RadGH/0b7ed53297483352c1c4