Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lootFilter() {
- function createLine() {
- let newLine = $('<div class="line">').css({
- display: 'flex',
- lineHeight: '19px',
- maxHeight: '19px'
- });
- for (var i = 0; i < arguments.length; i++) {
- newLine.append(arguments[i]);
- }
- return newLine;
- }
- var __this = this;
- var mainBox = $('<div id="lootfilter"></div>').css({
- width: 150,
- zIndex: 500,
- background: '#000',
- border: '2px solid #202020',
- color: '#e3e3e3',
- fontFamily: 'Arial, sans-serif',
- fontSize: '11px',
- textAlign: 'left',
- position: 'absolute',
- padding: '3px',
- cursor: 'grab',
- height: 38,
- overflow: 'hidden',
- borderRadius: '4px',
- boxShadow: '0 0 8px rgba(0, 0, 0, 0.8)'
- }).draggable({
- opacity: 0.7,
- start: function() {
- window.g.lock.add('dragging');
- window.Tip.disable();
- $(this).css({
- cursor: 'grabbing'
- });
- },
- stop: function() {
- __this.saveSettings();
- window.g.lock.remove('dragging');
- window.Tip.enable();
- $(this).css({
- cursor: 'grab'
- });
- }
- });
- $('<div></div>').attr({
- tip: 'Pokaż więcej opcji'
- }).css({
- backgroundImage: 'url(http://item.imgur.com/JnqHa4K.png)',
- backgroundSize: 15,
- height: '15px',
- width: '15px',
- position: 'absolute',
- top: '3px',
- right: '3px'
- }).toggle(function() {
- mainBox.stop().animate({
- height: 235
- }, 500)
- }, function() {
- mainBox.stop().animate({
- height: 38
- }, 500)
- }).appendTo(mainBox);
- var filterInput = $('<input>').css({
- backgroundColor: '#000',
- border: '1px solid #202020',
- padding: '1px',
- width: 50,
- color: '#e3e3e3',
- margin: 'auto 3px',
- borderRadius: '3px',
- fontSize: '11px'
- }).change(function() {
- __this.saveSettings()
- });
- var autoQuitCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_autoQuitCheckbox').change(function() {
- __this.saveSettings()
- });
- var legendaryCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_legendaryCheckbox').change(function() {
- __this.saveSettings()
- });
- var heroicCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_heroicCheckbox').change(function() {
- __this.saveSettings()
- });
- var uniqueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_uniqueCheckbox').change(function() {
- __this.saveSettings()
- });
- var mixCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_mixCheckbox').change(function() {
- __this.saveSettings()
- });
- var goldCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_goldCheckbox').change(function() {
- __this.saveSettings()
- });
- var arrowCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_arrowCheckbox').change(function() {
- __this.saveSettings()
- });
- var valueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_valueCheckbox').change(function() {
- __this.saveSettings()
- });
- var tpCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_tpCheckbox').change(function() {
- __this.saveSettings()
- });
- var runesCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_runesCheckbox').change(function() {
- __this.saveSettings()
- });
- var blessCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_blessCheckbox').change(function() {
- __this.saveSettings()
- });
- mainBox.append(createLine('<span style="font-weight: 700; padding-left: 3px">Loot Filter'));
- mainBox.append(createLine(valueCheckbox, '<label for="LFME_valueCheckbox" tip="Łapanie przedmiotów od określonej wartości">Powyżej: </label>', filterInput));
- mainBox.append($('<separator style="display: flex; height: 3px; border-bottom: 1px dotted #202020; margin-bottom: 3px">'));
- mainBox.append(createLine(legendaryCheckbox, '<label for="LFME_legendaryCheckbox" tip="Łapanie legend" style="color: #fa9a20">Legendarne</label>'));
- mainBox.append(createLine(heroicCheckbox, '<label for="LFME_heroicCheckbox" tip="Łapanie heroików" style="color: #2090fe">Heroiczne</label>'));
- mainBox.append(createLine(uniqueCheckbox, '<label for="LFME_uniqueCheckbox" tip="Łapanie unikatów" style="color: #daa520">Unikatowe</label>'));
- mainBox.append(createLine(mixCheckbox, '<label for="LFME_mixCheckbox" tip="Łapanie miksturek" style="color: #f0032a">Mikstury</label>'));
- mainBox.append(createLine(arrowCheckbox, '<label for="LFME_arrowCheckbox" tip="Łapanie strzałek" style="color: brown">Strzały</label>'));
- mainBox.append(createLine(tpCheckbox, '<label for="LFME_tpCheckbox" tip="Łapanie teleportów" style="color: green">Teleporty</label>'));
- mainBox.append(createLine(goldCheckbox, '<label for="LFME_goldCheckbox" tip="Łapanie złota" style="color: gold">Złoto</label>'));
- mainBox.append(createLine(runesCheckbox, '<label for="LFME_runesCheckbox" tip="Łapanie run" style="color: maroon">Runy</label>'));
- mainBox.append(createLine(blessCheckbox, '<label for="LFME_blessCheckbox" tip="Łapanie błogosławieństw" style="color: purple">Błogosławieństwa</label>'));
- mainBox.append(createLine(autoQuitCheckbox, '<label for="LFME_autoQuitCheckbox" tip="Automatyczne akceptowanie łupów">Akceptowanie łupów</label>'));
- $('body').append(mainBox);
- $('line > input[type="checkbox"]').css({
- margin: 'auto 3px'
- });
- this.saveSettings = function() {
- 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);
- };
- this.readSettings = function() {
- var settings = window.getCookie('lootfilter');
- if (!!localStorage.lootfilter) {
- settings = localStorage.lootfilter;
- }
- if (settings) {
- settings = settings.split('|');
- for (var i = 0; i < settings.length; i++) {
- var pair = settings[i].split(':');
- switch (pair[0]) {
- case 'top':
- mainBox.css('top', pair[1] + 'px');
- break;
- case 'left':
- mainBox.css('left', pair[1] + 'px');
- break;
- case 'value':
- filterInput.val(pair[1]);
- break;
- case 'autoQuit':
- if (parseInt(pair[1]) == 1) autoQuitCheckbox.attr('checked', 'checked');
- break;
- case 'leg':
- if (parseInt(pair[1]) == 1) legendaryCheckbox.attr('checked', 'checked');
- break;
- case 'her':
- if (parseInt(pair[1]) == 1) heroicCheckbox.attr('checked', 'checked');
- break;
- case 'uni':
- if (parseInt(pair[1]) == 1) uniqueCheckbox.attr('checked', 'checked');
- break;
- case 'mix':
- if (parseInt(pair[1]) == 1) mixCheckbox.attr('checked', 'checked');
- break;
- case 'gold':
- if (parseInt(pair[1]) == 1) goldCheckbox.attr('checked', 'checked');
- break;
- case 'arrow':
- if (parseInt(pair[1]) == 1) arrowCheckbox.attr('checked', 'checked');
- break;
- case 'val':
- if (parseInt(pair[1]) == 1) valueCheckbox.attr('checked', 'checked');
- break;
- case 'tp':
- if (parseInt(pair[1]) == 1) tpCheckbox.attr('checked', 'checked');
- break;
- case 'runes':
- if (parseInt(pair[1]) == 1) runesCheckbox.attr('checked', 'checked');
- break;
- case 'bless':
- if (parseInt(pair[1]) == 1) blessCheckbox.attr('checked', 'checked');
- break;
- }
- }
- } else {
- legendaryCheckbox.attr('checked', 'checked');
- heroicCheckbox.attr('checked', 'checked');
- uniqueCheckbox.attr('checked', 'checked');
- mixCheckbox.attr('checked', 'checked');
- goldCheckbox.attr('checked', 'checked');
- arrowCheckbox.attr('checked', 'checked');
- valueCheckbox.attr('checked', 'checked');
- tpCheckbox.attr('checked', 'checked');
- runesCheckbox.attr('checked', 'checked');
- blessCheckbox.attr('checked', 'checked');
- }
- };
- this.readSettings();
- const lootboxItemOld = window.lootboxItem;
- var sent = false;
- var loots = {
- want: [],
- not: [],
- must: []
- };
- window.lootboxItem = function(item) {
- lootboxItemOld(item);
- var stat = window.parseItemStat(item.stat);
- var limit = parseInt(filterInput.val());
- 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'))) {
- if (window.g.party && !(window.isset(stat.reqp) && stat.reqp.indexOf(window.hero.prof) == -1)) {
- loots.must.push(item.id);
- window.setStateOnOneLootItem(item.id, 2);
- } else {
- loots.want.push(item.id)
- window.setStateOnOneLootItem(item.id, 1);
- }
- } else {
- loots.not.push(item.id);
- window.setStateOnOneLootItem(item.id, 0);
- }
- if (!sent) {
- sent = true;
- setTimeout(function() {
- var autoQuit = autoQuitCheckbox.attr('checked') ? 1 : 0;
- window._g("loot&want=" + loots.want.join(",") + "¬=" + loots.not.join(",") + "&must=" + loots.must.join(",") + "&final=" + autoQuit);
- if (autoQuit) window.closeLootWindow();
- sent = false;
- loots = {
- want: [],
- not: [],
- must: []
- };
- }, 50);
- }
- }
- };
- window.g.loadQueue.push({
- fun: function() {
- var _lootfilter = new lootFilter();
- },
- data: ''
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement