Reputation Timer

http://hackforums.net/showthread.php?tid=5202767

  1. // ==UserScript==
  2. // @name Reputation Timer
  3. // @namespace Reputation Timer
  4. // @description http://hackforums.net/showthread.php?tid=5202767
  5. // @include *hackforums.net/reputation.php?action=add&uid=*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  7. // @version 0.1
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // ==/UserScript==
  11.  
  12. uid = GM_getValue("uid", true);
  13.  
  14. if (uid == true) {
  15. $.get("http://hackforums.net/index.php", function(data) {
  16. var regex = /Welcome back(.*?)strong/i;
  17. var match = regex.exec(data);
  18. uid = match[0].substr(79).split('"');
  19. GM_setValue("uid", uid[0]);
  20. });
  21. alert("Script successfully configured. Please reload.");
  22. } else {
  23. $(".smalltext").before("<div class='smalltext'>Reputations left today : <span id='repsLeft'></span></div>");
  24. $.get("http://hackforums.net/repsgiven.php?uid="+uid, function(data) {
  25. var date = [];
  26. $(data).find(".repvote .repvoteright").each(function(i) {
  27. date[i] = $(data).find("table.tborder:nth-child(2) > tbody:nth-child(1) > tr:nth-child("+(i+5)+") .repvote .repvoteright").html();
  28. });
  29. var match = [];
  30. for (var i = 0; i < 5; i++) {
  31. if (/(Today)/i.test(date[i]) == true) {
  32. match[i] = 1;
  33. } else if (/(Yesterday)/i.test(date[i]) == true) {
  34. var dateObj = new Date();
  35. var hour = dateObj.getHours();
  36. var minute = dateObj.getMinutes();
  37. var tempDate = date[i].substr(11).split(":");
  38. if (tempDate[0] > hour) {
  39. match[i] = 1;
  40. } else if (tempDate[0] == hour) {
  41. console.log("same h");
  42. if (tempDate[1] > minute) {
  43. match[i] = 1;
  44. }
  45. }
  46. }
  47. }
  48. left = 5 - match.length;
  49. $("#repsLeft").html(left);
  50. });
  51. }