Advertisement
HeroCC

A Script GitHub won't let me link to

Aug 31st, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var flairs = document.getElementsByTagName("span");
  2. var count = 0;
  3.  
  4. //find every flair on the page
  5. $('.flair').each(function(i, flair) {
  6.  
  7.     //get the reddit username
  8.     var username = $(flair).parent().find(".author").first().html();
  9.  
  10.     //check flair for a heatware URL
  11.     if(/.+heatware\.com.+/.test($(flair).html())){
  12.         var heatwareURL = $(flair).html().replace("http://", "https://"); //switch all heatware urls to HTTPS
  13.  
  14.         //get the user's heatware page
  15.         $.ajax({
  16.             url:heatwareURL,
  17.             success:function(data){
  18.  
  19.                 var parser=new DOMParser();
  20.                 $heatware = $("<div/>").html(data).contents();
  21.  
  22.                 profile = {};
  23.                 profile.verify = false;
  24.                 profile.url = heatwareURL;
  25.                
  26.                 //get # of pos/neu/neg evals
  27.                 profile.pos = $heatware.find('[title="Positive Evals"] .num1').text();
  28.                 profile.neu = $heatware.find('[title="Neutral Evals"] .num1').text();
  29.                 profile.neg = $heatware.find('[title="Negative Evals"] .num1').text();
  30.  
  31.                 //check if reddit alias on heatware matches reddit username
  32.                 $heatware.find('.subhead:contains(Aliases)').each(function(i, elem){
  33.                     if($(elem).parent().find('strong:contains(Reddit)').first().parent().text().indexOf(username+" ") == 0){
  34.                         profile.verify = true;
  35.                     };                   
  36.                 });
  37.  
  38.                 //replace flair with info
  39.                 var hwstr = "Heatware: "+profile.pos+" / "+profile.neu+" / "+profile.neg + " ("+(profile.verify ? "confirmed" : "unconfirmed")+")";
  40.                 $(flair).html("<a style='font-size:100% !important;font-weight:normal !important;' href='"+profile.url+"'>"+hwstr+"</a>"); 
  41.             }
  42.         });
  43.     }  
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement