Advertisement
Guest User

Save Liquibet

a guest
Feb 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     SAVE LIQUIBET
  3. // @version  1
  4. // @grant    none
  5. // @match https://www.liquidlegends.net/liquibet/
  6. // @require http://code.jquery.com/jquery-latest.js
  7. // ==/UserScript==
  8. $(document).ready(function() {
  9.     var ul = $('.liquibetForm').length;
  10.     var bps = 10;
  11.     var s = Math.ceil(ul / bps);
  12.  
  13.     var cb = $('<label class="saved">Hide Completed Bets<input id="hide" type="checkbox" /></label>');
  14.     var dd = '<select id="page" class="saved"><option value="all">all</value>';
  15.  
  16.     for (var j = 1; j <= s; j++) {
  17.         dd += '<option value="' + j + '">' + j + '</option>';
  18.     }
  19.  
  20.     dd += '</select>';
  21.  
  22.     $("#liquibet-upperLinks").append(dd);
  23.     $("#liquibet-upperLinks").append(cb);
  24.  
  25.     $(".saved").css('float', 'right');
  26.  
  27.     var i = 0;
  28.  
  29.     $(".liquibetForm").each(function() {
  30.         $(this).attr('BetNr', i)
  31.         i++;
  32.     });
  33.  
  34.     $("#hide").change(function() {
  35.         update();
  36.     });
  37.  
  38.     $("#page").change(function() {
  39.         update();
  40.     });
  41.  
  42.  
  43. })
  44.  
  45. function update() {
  46.     var c = $("#hide").is(":checked");
  47.     var p = $("#page").val();
  48.     var bps = 10;
  49.     var bet = 0;
  50.     var open = 0;
  51.     var ul = $('.liquibetForm').length;
  52.  
  53.     if (p == 'all') {
  54.         $(".liquibetForm").show();
  55.         if (c) {
  56.             $("span[data-bet-open='0']").parent().parent().parent().hide()
  57.         } else {
  58.             $("span[data-bet-open='0']").parent().parent().parent().show()
  59.         }
  60.     } else {
  61.         $(".liquibetForm").each(function() {
  62.  
  63.             bet = $(this).attr('BetNr');
  64.  
  65.  
  66.             if (bet <= (ul - (((p - 1) * bps))) && bet > (ul - (p * bps))) {
  67.  
  68.                 open = $(this).find(".teamVote").first().attr('data-bet-open');
  69.  
  70.                 if (c) {
  71.  
  72.                     if (open == 0) {
  73.                         $(this).hide();
  74.  
  75.                     } else {
  76.  
  77.                         $(this).show();
  78.                     }
  79.                 } else {
  80.                     $(this).show();
  81.                 }
  82.             } else {
  83.                 $(this).hide();
  84.             }
  85.  
  86.         });
  87.     }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement