Advertisement
Guest User

loot filter

a guest
Jul 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lootFilter() {
  2.     function createLine() {
  3.         let newLine = $('<div class="line">').css({
  4.             display: 'flex',
  5.             lineHeight: '19px',
  6.             maxHeight: '19px'
  7.         });
  8.         for (var i = 0; i < arguments.length; i++) {
  9.             newLine.append(arguments[i]);
  10.         }
  11.         return newLine;
  12.     }
  13.     var __this = this;
  14.     var mainBox = $('<div id="lootfilter"></div>').css({
  15.         width: 150,
  16.         zIndex: 500,
  17.         background: '#000',
  18.         border: '2px solid #202020',
  19.         color: '#e3e3e3',
  20.         fontFamily: 'Arial, sans-serif',
  21.         fontSize: '11px',
  22.         textAlign: 'left',
  23.         position: 'absolute',
  24.         padding: '3px',
  25.         cursor: 'grab',
  26.         height: 38,
  27.         overflow: 'hidden',
  28.         borderRadius: '4px',
  29.         boxShadow: '0 0 8px rgba(0, 0, 0, 0.8)'
  30.     }).draggable({
  31.         opacity: 0.7,
  32.         start: function() {
  33.             window.g.lock.add('dragging');
  34.             window.Tip.disable();
  35.             $(this).css({
  36.                 cursor: 'grabbing'
  37.             });
  38.         },
  39.         stop: function() {
  40.             __this.saveSettings();
  41.             window.g.lock.remove('dragging');
  42.             window.Tip.enable();
  43.             $(this).css({
  44.                 cursor: 'grab'
  45.             });
  46.         }
  47.     });
  48.     $('<div></div>').attr({
  49.         tip: 'Pokaż więcej opcji'
  50.     }).css({
  51.         backgroundImage: 'url(http://item.imgur.com/JnqHa4K.png)',
  52.         backgroundSize: 15,
  53.         height: '15px',
  54.         width: '15px',
  55.         position: 'absolute',
  56.         top: '3px',
  57.         right: '3px'
  58.     }).toggle(function() {
  59.         mainBox.stop().animate({
  60.             height: 235
  61.         }, 500)
  62.     }, function() {
  63.         mainBox.stop().animate({
  64.             height: 38
  65.         }, 500)
  66.     }).appendTo(mainBox);
  67.     var filterInput = $('<input>').css({
  68.         backgroundColor: '#000',
  69.         border: '1px solid #202020',
  70.         padding: '1px',
  71.         width: 50,
  72.         color: '#e3e3e3',
  73.         margin: 'auto 3px',
  74.         borderRadius: '3px',
  75.         fontSize: '11px'
  76.     }).change(function() {
  77.         __this.saveSettings()
  78.     });
  79.     var autoQuitCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_autoQuitCheckbox').change(function() {
  80.         __this.saveSettings()
  81.     });
  82.     var legendaryCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_legendaryCheckbox').change(function() {
  83.         __this.saveSettings()
  84.     });
  85.     var heroicCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_heroicCheckbox').change(function() {
  86.         __this.saveSettings()
  87.     });
  88.     var uniqueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_uniqueCheckbox').change(function() {
  89.         __this.saveSettings()
  90.     });
  91.     var mixCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_mixCheckbox').change(function() {
  92.         __this.saveSettings()
  93.     });
  94.     var goldCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_goldCheckbox').change(function() {
  95.         __this.saveSettings()
  96.     });
  97.     var arrowCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_arrowCheckbox').change(function() {
  98.         __this.saveSettings()
  99.     });
  100.     var valueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_valueCheckbox').change(function() {
  101.         __this.saveSettings()
  102.     });
  103.     var tpCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_tpCheckbox').change(function() {
  104.         __this.saveSettings()
  105.     });
  106.     var runesCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_runesCheckbox').change(function() {
  107.         __this.saveSettings()
  108.     });
  109.     var blessCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_blessCheckbox').change(function() {
  110.         __this.saveSettings()
  111.     });
  112.     mainBox.append(createLine('<span style="font-weight: 700; padding-left: 3px">Loot Filter'));
  113.     mainBox.append(createLine(valueCheckbox, '<label for="LFME_valueCheckbox" tip="Łapanie przedmiotów od określonej wartości">Powyżej: </label>', filterInput));
  114.     mainBox.append($('<separator style="display: flex; height: 3px; border-bottom: 1px dotted #202020; margin-bottom: 3px">'));
  115.     mainBox.append(createLine(legendaryCheckbox, '<label for="LFME_legendaryCheckbox" tip="Łapanie legend" style="color: #fa9a20">Legendarne</label>'));
  116.     mainBox.append(createLine(heroicCheckbox, '<label for="LFME_heroicCheckbox" tip="Łapanie heroików" style="color: #2090fe">Heroiczne</label>'));
  117.     mainBox.append(createLine(uniqueCheckbox, '<label for="LFME_uniqueCheckbox" tip="Łapanie unikatów" style="color: #daa520">Unikatowe</label>'));
  118.     mainBox.append(createLine(mixCheckbox, '<label for="LFME_mixCheckbox" tip="Łapanie miksturek" style="color: #f0032a">Mikstury</label>'));
  119.     mainBox.append(createLine(arrowCheckbox, '<label for="LFME_arrowCheckbox" tip="Łapanie strzałek" style="color: brown">Strzały</label>'));
  120.     mainBox.append(createLine(tpCheckbox, '<label for="LFME_tpCheckbox" tip="Łapanie teleportów" style="color: green">Teleporty</label>'));
  121.     mainBox.append(createLine(goldCheckbox, '<label for="LFME_goldCheckbox" tip="Łapanie złota" style="color: gold">Złoto</label>'));
  122.     mainBox.append(createLine(runesCheckbox, '<label for="LFME_runesCheckbox" tip="Łapanie run" style="color: maroon">Runy</label>'));
  123.     mainBox.append(createLine(blessCheckbox, '<label for="LFME_blessCheckbox" tip="Łapanie błogosławieństw" style="color: purple">Błogosławieństwa</label>'));
  124.     mainBox.append(createLine(autoQuitCheckbox, '<label for="LFME_autoQuitCheckbox" tip="Automatyczne akceptowanie łupów">Akceptowanie łupów</label>'));
  125.     $('body').append(mainBox);
  126.     $('line > input[type="checkbox"]').css({
  127.         margin: 'auto 3px'
  128.     });
  129.     this.saveSettings = function() {
  130.         localStorage.lootfilter = 'top:' + mainBox.offset().top + '|left:' + mainBox.offset().left + '|value:' + filterInput.val() + '|autoQuit:' + (autoQuitCheckbox.attr('checked') ? 1 : 0) + '|leg:' + (legendaryCheckbox.attr('checked') ? 1 : 0) + '|her:' + (heroicCheckbox.attr('checked') ? 1 : 0) + '|uni:' + (uniqueCheckbox.attr('checked') ? 1 : 0) + '|bless:' + (blessCheckbox.attr('checked') ? 1 : 0) + '|mix:' + (mixCheckbox.attr('checked') ? 1 : 0) + '|gold:' + (goldCheckbox.attr('checked') ? 1 : 0) + '|arrow:' + (arrowCheckbox.attr('checked') ? 1 : 0) + '|val:' + (valueCheckbox.attr('checked') ? 1 : 0) + '|tp:' + (tpCheckbox.attr('checked') ? 1 : 0) + '|runes:' + (runesCheckbox.attr('checked') ? 1 : 0);
  131.     };
  132.     this.readSettings = function() {
  133.         var settings = window.getCookie('lootfilter');
  134.         if (!!localStorage.lootfilter) {
  135.             settings = localStorage.lootfilter;
  136.         }
  137.         if (settings) {
  138.             settings = settings.split('|');
  139.             for (var i = 0; i < settings.length; i++) {
  140.                 var pair = settings[i].split(':');
  141.                 switch (pair[0]) {
  142.                     case 'top':
  143.                         mainBox.css('top', pair[1] + 'px');
  144.                         break;
  145.                     case 'left':
  146.                         mainBox.css('left', pair[1] + 'px');
  147.                         break;
  148.                     case 'value':
  149.                         filterInput.val(pair[1]);
  150.                         break;
  151.                     case 'autoQuit':
  152.                         if (parseInt(pair[1]) == 1) autoQuitCheckbox.attr('checked', 'checked');
  153.                         break;
  154.                     case 'leg':
  155.                         if (parseInt(pair[1]) == 1) legendaryCheckbox.attr('checked', 'checked');
  156.                         break;
  157.                     case 'her':
  158.                         if (parseInt(pair[1]) == 1) heroicCheckbox.attr('checked', 'checked');
  159.                         break;
  160.                     case 'uni':
  161.                         if (parseInt(pair[1]) == 1) uniqueCheckbox.attr('checked', 'checked');
  162.                         break;
  163.                     case 'mix':
  164.                         if (parseInt(pair[1]) == 1) mixCheckbox.attr('checked', 'checked');
  165.                         break;
  166.                     case 'gold':
  167.                         if (parseInt(pair[1]) == 1) goldCheckbox.attr('checked', 'checked');
  168.                         break;
  169.                     case 'arrow':
  170.                         if (parseInt(pair[1]) == 1) arrowCheckbox.attr('checked', 'checked');
  171.                         break;
  172.                     case 'val':
  173.                         if (parseInt(pair[1]) == 1) valueCheckbox.attr('checked', 'checked');
  174.                         break;
  175.                     case 'tp':
  176.                         if (parseInt(pair[1]) == 1) tpCheckbox.attr('checked', 'checked');
  177.                         break;
  178.                     case 'runes':
  179.                         if (parseInt(pair[1]) == 1) runesCheckbox.attr('checked', 'checked');
  180.                         break;
  181.                     case 'bless':
  182.                         if (parseInt(pair[1]) == 1) blessCheckbox.attr('checked', 'checked');
  183.                         break;
  184.                 }
  185.             }
  186.         } else {
  187.             legendaryCheckbox.attr('checked', 'checked');
  188.             heroicCheckbox.attr('checked', 'checked');
  189.             uniqueCheckbox.attr('checked', 'checked');
  190.             mixCheckbox.attr('checked', 'checked');
  191.             goldCheckbox.attr('checked', 'checked');
  192.             arrowCheckbox.attr('checked', 'checked');
  193.             valueCheckbox.attr('checked', 'checked');
  194.             tpCheckbox.attr('checked', 'checked');
  195.             runesCheckbox.attr('checked', 'checked');
  196.             blessCheckbox.attr('checked', 'checked');
  197.         }
  198.     };
  199.     this.readSettings();
  200.     const lootboxItemOld = window.lootboxItem;
  201.     var sent = false;
  202.     var loots = {
  203.         want: [],
  204.         not: [],
  205.         must: []
  206.     };
  207.     window.lootboxItem = function(item) {
  208.         lootboxItemOld(item);
  209.         var stat = window.parseItemStat(item.stat);
  210.         var limit = parseInt(filterInput.val());
  211.         if ((item.stat.includes('ttl') && blessCheckbox.attr('checked')) || item.stat.includes('quest') || (item.stat.includes('legendary') && legendaryCheckbox.attr('checked')) || (item.stat.includes('heroic') && heroicCheckbox.attr('checked')) || (item.stat.includes('unique') && uniqueCheckbox.attr('checked')) || ((item.stat.includes('fullheal') || item.stat.includes('leczy') || item.stat.includes('perheal')) && mixCheckbox.attr('checked')) || (item.stat.includes('ammo') && arrowCheckbox.attr('checked')) || (item.stat.includes('gold') && goldCheckbox.attr('checked')) || (item.stat.includes('teleport') && tpCheckbox.attr('checked')) || (item.stat.includes('runes') && runesCheckbox.attr('checked'))) {
  212.             if (window.g.party && !(window.isset(stat.reqp) && stat.reqp.indexOf(window.hero.prof) == -1)) {
  213.                 loots.must.push(item.id);
  214.                 window.setStateOnOneLootItem(item.id, 2);
  215.             } else {
  216.                 loots.want.push(item.id)
  217.                 window.setStateOnOneLootItem(item.id, 1);
  218.             }
  219.         } else {
  220.             loots.not.push(item.id);
  221.             window.setStateOnOneLootItem(item.id, 0);
  222.         }
  223.         if (!sent) {
  224.             sent = true;
  225.             setTimeout(function() {
  226.                 var autoQuit = autoQuitCheckbox.attr('checked') ? 1 : 0;
  227.                 window._g("loot&want=" + loots.want.join(",") + "&not=" + loots.not.join(",") + "&must=" + loots.must.join(",") + "&final=" + autoQuit);
  228.                 if (autoQuit) window.closeLootWindow();
  229.                 sent = false;
  230.                 loots = {
  231.                     want: [],
  232.                     not: [],
  233.                     must: []
  234.                 };
  235.             }, 50);
  236.         }
  237.     }
  238. };
  239. window.g.loadQueue.push({
  240.     fun: function() {
  241.         var _lootfilter = new lootFilter();
  242.     },
  243.     data: ''
  244. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement