Advertisement
EyEBURNeR

sgpanu

May 11th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. // ==UserScript==
  2. // @id sgpanu
  3. // @name sgpanu
  4. // @version 1.1
  5. // @namespace
  6. // @author EyEBURNeR
  7. // @description ga parser
  8. // @include http://www.steamgifts.com/manage/created/panu*
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. var $ = unsafeWindow.jQuery;
  13.  
  14.  
  15. $('.search.disabled').after($('<button/>').click(parseEleg).text('ELEG')).after($('<textarea/>').attr('id','eleg')).remove();
  16.  
  17. bundle_list=[];
  18.  
  19. function parseEleg(){
  20. $('.bg_gradient:first').append($('<table/>').attr('id','galist'));
  21. $('#galist').attr('style','background:white;margin:8px;padding:8px;border:2px solid #777;');
  22. parseList($('#eleg').val());
  23. }
  24.  
  25. function parseList(page){
  26. var list=$('.forum_op .content', $(page));
  27. var ga_list=[];
  28. $('a', list).each(function(){
  29. ga_list.push($(this).attr('href'));
  30. });
  31. for(i in ga_list){
  32. loadGa(ga_list[i]);
  33. }
  34.  
  35. }
  36.  
  37. function loadGa(url){
  38. $.ajax({
  39. url: url,
  40. async : false,
  41. success: function (page) {
  42. parseGa(page,url);
  43. },
  44. dataType: 'html'
  45. });
  46. }
  47.  
  48. var previous_giver='';
  49. function parseGa(page, url){
  50. var text='';
  51. var title=$.trim( $('.featured .title', page ).contents(':not(span)').text() );
  52. var is_bundle=($.inArray(title, bundle_list)>-1);
  53. var giver=$('.hosted_by a span',page).text();
  54. if(previous_giver!=giver)
  55. text+='<br/>';
  56. previous_giver=giver;
  57.  
  58. var winners=[];
  59. var is_failed=false;
  60. var is_closed=$('.winners_heading',page).length;
  61.  
  62. text='<a href="'+url+'">'+url+'</a>';
  63. if(is_closed){
  64.  
  65. var received=$('.winners .username',page);
  66.  
  67. if(received.length){
  68. $('.winners .username a', page).each(function(){
  69. if($(this).closest('.details').find('.negative').length){
  70. winners.push('NOT RECEIVED');
  71. }else{
  72. winners.push($(this).text());
  73. }
  74.  
  75. });
  76. }else{
  77. winners.push('FAILED');
  78. is_failed=true;
  79. }
  80. if(!winners.length){
  81. $('#galist').append('<tr><td>'+text+'</td><td>PENDING</td>');
  82. return true; // WAITING confirmation
  83. }
  84. $('#galist').append('<tr><td>'+text+'</td><td>'+winners.join(',')+'</td>');
  85.  
  86. return true;
  87. }else{
  88. $('#galist').append('<tr><td>'+text+'</td><td>OPEN</td>');
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement