Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lootFilter() {
- let css = document.createElement('style');
- css.innerHTML = "#lootfilter { width: 150px; right: 0; top: 0; position: absolute; }"
- document.body.appendChild(css);
- var settings;
- if (!localStorage.getItem('lootfilter-settings')) {
- settings = {
- posX: 50,
- posY: 50,
- value: 0,
- setValue: '',
- legendary: 1,
- heroic: 1,
- unique: 1,
- heal: 1,
- arrow: 1,
- gold: 1,
- teleport: 1,
- runes: 1,
- bless: 1,
- close: 0
- }
- localStorage.setItem('lootfilter-settings', JSON.stringify(settings));
- }
- settings = JSON.parse(localStorage.getItem('lootfilter-settings'));
- function updateSettings(id, val) {
- settings = JSON.parse(localStorage.getItem('lootfilter-settings'));
- settings[id] = val;
- console.log(id, settings[id])
- localStorage.setItem('lootfilter-settings', JSON.stringify(settings));
- }
- function createLi(id, text, tip) {
- let liElement = document.createElement('li');
- liElement.setAttribute('data-id', id);
- if (tip) liElement.setAttribute('tip', tip);
- let checkboxElement = document.createElement('input');
- checkboxElement.setAttribute('type', 'checkbox');
- if(settings[id]) checkboxElement.checked = true;
- checkboxElement.addEventListener('change', function() {
- updateSettings(id, settings[id] ? 0 : 1)
- });
- liElement.appendChild(checkboxElement);
- let textElement = document.createElement('span');
- textElement.textContent = text;
- liElement.appendChild(textElement);
- ulElement.appendChild(liElement);
- }
- let mainBox = document.createElement('div');
- mainBox.setAttribute('id', 'lootfilter');
- let header = document.createElement('header');
- let name = document.createElement('span');
- name.textContent = 'Loot Filter';
- header.appendChild(name);
- let options = document.createElement('span');
- options.setAttribute('id', 'options');
- options.setAttribute('tip', 'Pokaż więcej opcji');
- options.textContent = 'opcje';
- header.appendChild(options);
- mainBox.appendChild(header);
- let ulElement = document.createElement('ul');
- createLi('value', 'Powyżej', 'Łapanie przedmiotów od określonej wartości')
- createLi('legendary', 'Legendarne', 'Łapanie legend');
- createLi('heroic', 'Heroiczne', 'Łapanie heroików');
- createLi('unique', 'Unikatowe', 'Łapanie unikatów');
- createLi('heal', 'Mikstury', 'Łapanie mikstur');
- createLi('arrow', 'Strzały', 'Łapanie strzał');
- createLi('teleport', 'Teleporty', 'Łapanie teleportów');
- createLi('gold', 'Złoto', 'Łapanie złota');
- createLi('runes', 'Smocze runy', 'Łapanie smoczych run');
- createLi('bless', 'Błogosławieństwa', 'Łapanie błogosławieństw');
- createLi('close', 'Podział łupów', 'Akceptowanie podziału łupów');
- mainBox.appendChild(ulElement);
- document.body.appendChild(mainBox);
- let inputValue = document.createElement('input');
- inputValue.setAttribute('id', 'value');
- inputValue.addEventListener('change', function(){
- updateSettings('setValue', inputValue.value)
- })
- document.querySelector('ul > li[data-id="value"]').appendChild(inputValue);
- $('#lootfilter').draggable({
- cancel: '#lootfilter > ul',
- start: () => {
- window.g.lock.add('dragging');
- window.Tip.disable();
- },
- stop: () => {
- window.g.lock.remove('dragging');
- window.Tip.enable();
- updateSettings('posX', parseInt(mainBox.style.left));
- updateSettings('posY', parseInt(mainBox.style.top));
- }
- });
- mainBox.style.left = settings.posX + "px";
- mainBox.style.top = settings.posY + "px";
- const lootItemOld = window.lootItem;
- var sent = false;
- var loots;
- window.lootItem = function(item) {
- lootItemOld(item);
- var stat = window.parseItemStat(item.stat);
- if (!sent) loots = {want: [], not: [], must: []};
- if (((isNaN(parseInt(settings.setValue)) || (item.pr >= parseInt(settings.setValue))) && settings.value) || (item.stat.includes('ttl') && settings.bless) || item.stat.includes('quest') || (item.stat.includes('legendary') && settings.legendary) || (item.stat.includes('heroic') && settings.heroic) || (item.stat.includes('unique') && settings.unique) || ((item.stat.includes('fullheal') || item.stat.includes('leczy') || item.stat.includes('perheal')) && settings.heal) || (item.stat.includes('ammo') && settings.arrow) || (item.stat.includes('gold') && settings.gold) || (item.stat.includes('teleport') && settings.teleport) || (item.stat.includes('runes') && settings.teleport)) {
- 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;
- if (settings.close && window.g.party) window._g('chat&c=/g .');
- setTimeout(function() {
- window._g("loot&want=" + loots.want.join(",") + "¬=" + loots.not.join(",") + "&must=" + loots.must.join(",") + "&final=" + settings.close);
- if (settings.close) window.closeLootWindow();
- sent = false;
- }, 300);
- }
- }
- }
- window.g.loadQueue.push({
- fun: function() {
- var _lootfilter = new lootFilter();
- },
- data: ''
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement