- Experimental Feature: Event Items Store Category - Fixed "Try On" store items - Deleted "Try On" store items code and moved it to the main item view page script - Fixed Transactions page Bricks to IRL Price converter - Transactions page bricks to IRL Price converter now doesn't say "$NaN" when the input is erased - Deleted popup and installation HTML files as they aren't used and haven't been used for a while. I am thinking of adding a new popup when you click the extension icon in your browser toolbar but that will be different than the code that was there. - New Feature: Show "Owners" instead of "Sales" - Updated theme code to run on all pages, even when the "Theme Creator" feature is turned off so that CSS such as modal CSS can still apply without other scripts having to apply their own CSS blob to the page - Updated context menu background code to remove all context menus created by the extension before creating the context menus so the error for duplicate context menu IDs won't keep appearing (hopefully, but I haven't gotten the error yet so...) - Fixed "Trending Items" IRL Brick price breaking if any of the trending items are free - Improved detection for the purchase button on item view pages - Fixed the item view page not checking if the item isn't owned before trying to add the IRL Brick price - Removed old setTimeout() code at the start of some files
109 lines
No EOL
4.3 KiB
JavaScript
Executable file
109 lines
No EOL
4.3 KiB
JavaScript
Executable file
var SelectedTrades = []
|
|
|
|
let Parent = document.getElementsByClassName('card mcard p-5 text-center text-muted')[0].parentElement
|
|
let Text = document.createElement('p')
|
|
Text.classList = 'mx-auto'
|
|
Text.style.textAlign = 'center'
|
|
Text.style.fontSize = '1.3rem'
|
|
Text.innerHTML = `
|
|
<span>0</span> trades selected!
|
|
<br>
|
|
<button id="viewSelectionBtn" class="btn btn-primary">View Selection</button>
|
|
<button id="clearSelectionBtn" class="btn btn-warning">Clear Selection</button>
|
|
<button id="cancelSelectionBtn" class="btn btn-danger">Cancel Selected Trades</button>
|
|
`
|
|
Parent.insertBefore(Text, Parent.children[0])
|
|
let Text_Span = Text.querySelector('span');
|
|
let Text_View = document.getElementById('viewSelectionBtn');
|
|
let Text_Clear = document.getElementById('clearSelectionBtn');
|
|
let Text_Cancel = document.getElementById('cancelSelectionBtn');
|
|
|
|
var ConfirmCancel = 0
|
|
Text_View.addEventListener('click', function(){});
|
|
Text_Clear.addEventListener('click', function(){
|
|
SelectedTrades = []
|
|
UpdateCheckboxes();
|
|
Text_Span.innerText = SelectedTrades.length
|
|
});
|
|
Text_Cancel.addEventListener('click', function(){
|
|
ConfirmCancel = ConfirmCancel + 1
|
|
switch(ConfirmCancel) {
|
|
case 0:
|
|
Text_Cancel.innerText = 'Cancel Selected Trades'
|
|
break
|
|
case 1:
|
|
Text_Cancel.innerText = 'Are you sure?'
|
|
break
|
|
case 2:
|
|
let Success = true
|
|
for (let i = 0; i < SelectedTrades.length; i++) {
|
|
setTimeout(function () {}, 110)
|
|
console.log(SelectedTrades[i])
|
|
fetch('https://polytoria.com/api/trade/decline', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRF-Token': document.querySelector('input[name="_csrf"]').value
|
|
},
|
|
body: JSON.stringify({ id: SelectedTrades[i] }),
|
|
})
|
|
.catch(error => {
|
|
// Handle any errors
|
|
console.error('Error:', error);
|
|
Success = false
|
|
});
|
|
}
|
|
SelectedTrades = []
|
|
UpdateCheckboxes();
|
|
Text_Cancel.innerText = 'Cancel Selected Trades'
|
|
ConfirmCancel = 0
|
|
break
|
|
}
|
|
});
|
|
|
|
LoadCheckBoxes();
|
|
|
|
function LoadCheckBoxes() {
|
|
Array.from(document.getElementsByClassName('card-inbox')).forEach(element => {
|
|
let ViewBtn = element.querySelector('a.btn.btn-primary')
|
|
let TradeID = parseInt(ViewBtn.getAttribute('href').split('/')[3])
|
|
var NewCheckBox = document.createElement('button')
|
|
NewCheckBox.classList = 'polyplus-multicanceltr-checkbox'
|
|
NewCheckBox.setAttribute('style', 'padding: 20px; background-color: #191919; border: 1px solid #393939; border-radius: 1rem; margin-left: 10px;')
|
|
var Index = SelectedTrades.indexOf(TradeID)
|
|
if (Index !== -1) {
|
|
NewCheckBox.style.borderColor = 'lime'
|
|
}
|
|
ViewBtn.parentElement.appendChild(NewCheckBox)
|
|
NewCheckBox.addEventListener('click', function(){
|
|
var Index = SelectedTrades.indexOf(TradeID)
|
|
if (Index === -1) {
|
|
SelectedTrades.push(TradeID)
|
|
NewCheckBox.style.borderColor = 'lime'
|
|
} else {
|
|
SelectedTrades.splice(Index, 1)
|
|
NewCheckBox.style.borderColor = '#393939'
|
|
}
|
|
Text_Span.innerText = SelectedTrades.length
|
|
UpdateCheckboxes();
|
|
});
|
|
});
|
|
}
|
|
|
|
function UpdateCheckboxes(){
|
|
document.querySelectorAll('.polyplus-multicanceltr-checkbox').forEach(element => {
|
|
let Parent = element.parentElement
|
|
let ViewBtn = Parent.querySelector('a.btn.btn-primary')
|
|
if (element.getAttribute('disabled')) {
|
|
element.removeAttribute('disabled')
|
|
}
|
|
if (SelectedTrades.IndexOf(ViewBtn.getAttribute('data-user-id')) === -1) {
|
|
element.style.borderColor = '#393939'
|
|
} else {
|
|
element.style.borderColor = 'lime'
|
|
if (SelectedTrades.length >= 10) {
|
|
element.setAttribute('disabled', true)
|
|
}
|
|
}
|
|
})
|
|
} |