bug fixes and remove prettier github action
This commit is contained in:
parent
4bf9139a60
commit
1a2af482aa
15 changed files with 211 additions and 327 deletions
51
.github/workflows/prettier.yml
vendored
51
.github/workflows/prettier.yml
vendored
|
|
@ -1,51 +0,0 @@
|
|||
name: Prettier Format and Commit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'refs/heads/*'
|
||||
|
||||
jobs:
|
||||
prettier:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'latest'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Pull latest changes
|
||||
run: git pull
|
||||
|
||||
- name: Run Prettier
|
||||
run: npx prettier --write .
|
||||
|
||||
- name: Commit changes
|
||||
id: commit
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
if git diff-index --quiet HEAD; then
|
||||
echo "No changes to commit."
|
||||
echo "changes_committed=false" >> $GITHUB_ENV
|
||||
else
|
||||
git commit -m "chore: format code with Prettier"
|
||||
echo "changes_committed=true" >> $GITHUB_ENV
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Push changes
|
||||
if: env.changes_committed == 'true'
|
||||
run: git push
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
|||
.DS_Store
|
||||
/node_modules/
|
||||
17
.prettierrc
17
.prettierrc
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"arrowParens": "always",
|
||||
"bracketSpacing": false,
|
||||
"printWidth": 200,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"useTabs": true,
|
||||
"plugins": ["prettier-plugin-jinja-template"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.html",
|
||||
"options": {
|
||||
"parser": "jinja-template"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ let Utilities;
|
|||
chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) {
|
||||
Settings = result.PolyPlus_Settings || Utilities.DefaultSettings;
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
IRLPrice();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ if (UserID) {
|
|||
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
||||
Settings = result.PolyPlus_Settings || {};
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
IRLPrice();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ let Utilities;
|
|||
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
||||
Settings = result.PolyPlus_Settings;
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
(async () => {
|
||||
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
|
||||
Utilities = Utilities.default;
|
||||
|
|
@ -40,7 +40,7 @@ const observer = new MutationObserver(async function (list) {
|
|||
for (const record of list) {
|
||||
for (const element of record.addedNodes) {
|
||||
if (element.tagName === 'DIV' && element.classList.value === 'col-auto mb-3') {
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
IRLPrice(element);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
const AssetID = window.location.pathname.split('/')[2];
|
||||
const LibraryType = document.querySelectorAll('ol a')[1].innerText;
|
||||
const LibraryTypes = ['Models', 'Audio', 'Decal', 'Mesh'];
|
||||
const LibraryType = document.querySelectorAll('ol a')[1].innerText.toLowerCase();
|
||||
const LibraryTypes = ['model', 'audio', 'decal', 'mesh'];
|
||||
|
||||
if (LibraryTypes.indexOf(LibraryType) !== -1) {
|
||||
if (LibraryTypes.filter((x) => !LibraryTypes.some(element => element.startsWith(LibraryType))).length > 0) {
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
||||
Settings = result.PolyPlus_Settings || {};
|
||||
|
||||
|
|
@ -19,21 +19,21 @@ if (LibraryTypes.indexOf(LibraryType) !== -1) {
|
|||
Dropdown.insertBefore(DownloadLink, Dropdown.children[Dropdown.children.length - 1]);
|
||||
|
||||
switch (LibraryType) {
|
||||
case 'Models':
|
||||
case LibraryType.startsWith('model'):
|
||||
DownloadLink.href = 'https://api.polytoria.com/v1/models/get-model?id=' + AssetID;
|
||||
break;
|
||||
case 'Audio':
|
||||
case LibraryType.startsWith('audio'):
|
||||
const AudioBlob = new Blob([document.getElementsByTagName('audio')[0]], {type: 'octet-steam'});
|
||||
DownloadLink.href = URL.createObjectURL(AudioBlob);
|
||||
DownloadLink.download = document.getElementsByTagName('h1')[0].innerText + '.mp3';
|
||||
case 'Decal':
|
||||
case LibraryType.startsWith('decal'):
|
||||
const DecalBlob = new Blob([document.getElementsByClassName('store-thumbnail')[0]], {type: 'image/png'});
|
||||
DownloadLink.href = URL.createObjectURL(DecalBlob);
|
||||
DownloadLink.download = document.getElementsByTagName('h1')[0].innerText + '.png';
|
||||
break;
|
||||
}
|
||||
|
||||
if (LibraryType === 'Mesh') {
|
||||
if (LibraryType.startsWith('mesh')) {
|
||||
let MeshURL = null;
|
||||
DownloadLink.addEventListener('click', async function () {
|
||||
if (MeshURL !== null) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ const Gamepasses = Array.from(GamepassesTab.getElementsByClassName('card')) || [
|
|||
}
|
||||
}
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
IRLPrice();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ let Theme = ``;
|
|||
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
||||
|
||||
// If theme exists, create a style element to represent it
|
||||
if (Settings.ThemeCreator.Enabled && Settings.ThemeCreator.Enabled === true) {
|
||||
if (Settings.ThemeCreator && Settings.ThemeCreator.Enabled === true) {
|
||||
switch (Settings.ThemeCreator.BGImageSize) {
|
||||
case 0:
|
||||
Settings.ThemeCreator.BGImageSize = 'fit';
|
||||
|
|
@ -113,8 +113,8 @@ let Theme = ``;
|
|||
}
|
||||
});
|
||||
|
||||
if (Settings.HideUserAds.Enabled === true) {
|
||||
if (Settings.HideUserAds.Banners === true) {
|
||||
if (Settings.HideUserAds && Settings.HideUserAds.Enabled === true) {
|
||||
if (Settings.HideUserAds.Banners && Settings.HideUserAds.Banners === true) {
|
||||
Theme += `
|
||||
div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
|
||||
display: none;
|
||||
|
|
@ -122,7 +122,7 @@ let Theme = ``;
|
|||
`;
|
||||
}
|
||||
|
||||
if (Settings.HideUserAds.Rectangles === true) {
|
||||
if (Settings.HideUserAds.Rectangles && Settings.HideUserAds.Rectangles === true) {
|
||||
Theme += `
|
||||
div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
|
||||
display: none;
|
||||
|
|
@ -154,7 +154,7 @@ let Theme = ``;
|
|||
|
||||
const UserData = JSON.parse(window.localStorage.getItem('p+account_info'));
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
const IRLResult = await Utilities.CalculateIRL(document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g, ''), Settings.IRLPriceWithCurrency.Currency);
|
||||
// Desktop
|
||||
document.querySelector('.text-success .brickBalanceCount').innerHTML += ` (${IRLResult.icon}${IRLResult.result} ${IRLResult.display})`;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var Utilities;
|
|||
Utilities.InjectResource('registerTooltips');
|
||||
}
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
|
||||
IRLPrice();
|
||||
}
|
||||
|
||||
|
|
@ -54,11 +54,10 @@ var Utilities;
|
|||
}
|
||||
|
||||
if (document.getElementById('resellers') !== null) {
|
||||
if (Settings.HoardersList.Enabled === true) {
|
||||
console.log(parseInt(Settings.HoardersList.MinCopies));
|
||||
if (Settings.HoardersList && Settings.HoardersList.Enabled === true) {
|
||||
HoardersList(parseInt(Settings.HoardersList.MinCopies), Settings.HoardersList.AvatarsEnabled);
|
||||
}
|
||||
} else if (document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) {
|
||||
} else if (Settings.ItemOwnerCheckOn === true && document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) {
|
||||
CheckOwner();
|
||||
}
|
||||
});
|
||||
|
|
@ -301,16 +300,17 @@ function TryOnItems() {
|
|||
TryOnModal.classList = 'polyplus-modal';
|
||||
TryOnModal.setAttribute('style', 'width: 450px; border: 1px solid #484848; background-color: #181818; border-radius: 20px; overflow: hidden;');
|
||||
TryOnModal.innerHTML = `
|
||||
<div class="row text-muted mb-2" style="font-size: 0.8rem;">
|
||||
<div class="col">
|
||||
<h5 class="mb-0" style="color: #fff;">Preview</h5>
|
||||
Try this avatar on your avatar before purchasing it!
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-info w-100 mx-auto" onclick="this.parentElement.parentElement.parentElement.close();">X</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
<div class="row text-muted mb-2" style="font-size: 0.8rem;">
|
||||
<div class="col">
|
||||
<h5 class="mb-0" style="color: #fff;">Preview</h5>
|
||||
Try this avatar on your avatar before purchasing it!
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-info w-100 mx-auto" onclick="this.parentElement.parentElement.parentElement.close();">X</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
`;
|
||||
|
||||
document.body.prepend(TryOnModal);
|
||||
|
|
@ -400,16 +400,27 @@ async function HoardersList(min, avatars) {
|
|||
}
|
||||
}
|
||||
|
||||
let AvatarsFetched = 0;
|
||||
let Hoarders = await new Promise(async (resolve, reject) => {
|
||||
const Sorted = Object.values(Formatted)
|
||||
.filter((x, index) => x.copies >= min)
|
||||
.sort((a, b) => b.copies - a.copies);
|
||||
const FormattedValues = Object.values(Formatted).filter((x, index) => x.copies >= 2)
|
||||
if (avatars === true) {
|
||||
for (let hoarder of Sorted) {
|
||||
const Avatar = (await (await fetch('https://api.polytoria.com/v1/users/' + hoarder.user.id)).json()).thumbnail.icon;
|
||||
hoarder.user.avatar = Avatar;
|
||||
for (let hoarder of FormattedValues) {
|
||||
if (AvatarsFetched < 15) {
|
||||
try {
|
||||
AvatarsFetched++
|
||||
const Avatar = (await (await fetch('https://api.polytoria.com/v1/users/' + hoarder.user.id)).json());
|
||||
console.log(hoarder.user.username, Avatar)
|
||||
hoarder.user.avatar = Avatar.thumbnail.icon;
|
||||
} catch(error) {
|
||||
hoarder.user.avatar = ''
|
||||
console.log(hoarder.user.username + ` (${hoarder.user.id}) - avatar failed`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const Sorted = FormattedValues
|
||||
.filter((x, index) => x.copies >= min)
|
||||
.sort((a, b) => b.copies - a.copies);
|
||||
resolve(Sorted);
|
||||
});
|
||||
let AmountOfHoarders = Hoarders.length;
|
||||
|
|
@ -421,91 +432,79 @@ async function HoardersList(min, avatars) {
|
|||
}
|
||||
|
||||
TabContent.innerHTML = `
|
||||
<div id="p+hoarders-container">
|
||||
${
|
||||
Groups[Page] !== undefined
|
||||
? Groups[Page].map(
|
||||
(x) => `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
${
|
||||
avatars === true
|
||||
? `
|
||||
<div class="col-auto">
|
||||
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
|
||||
</div>
|
||||
`
|
||||
: ''
|
||||
<div id="p+hoarders-container">
|
||||
${ Groups[Page] !== undefined ? Groups[Page].map((x) => `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
${ avatars === true ? `
|
||||
<div class="col-auto">
|
||||
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
|
||||
</div>
|
||||
` : ''
|
||||
}
|
||||
<div class="col d-flex align-items-center">
|
||||
<div>
|
||||
<h6 class="mb-1">
|
||||
<a class="text-reset" href="/users/${x.user.id}">${x.user.username}</a>
|
||||
</h6>
|
||||
<small class="text-muted">${x.copies} Copies <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="#${x.serials.sort((a, b) => a - b).join(', #')}"></i></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<!--
|
||||
<div>
|
||||
<h5 style="margin: 0px;margin-right: 10px;">${((x.copies / InitialOwners.total) * 100).toFixed(2)}%</h5>
|
||||
</div>
|
||||
-->
|
||||
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
|
||||
<i class="fad fa-exchange-alt me-1"></i>
|
||||
<span class="d-none d-sm-inline">Trade</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
).join('')
|
||||
: `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body text-center py-5 text-muted">
|
||||
<h1 class="display-3"><i class="fa-solid fa-rectangle-history-circle-user"></i></h1>
|
||||
<h5> No hoarders </h5>
|
||||
<p class="mb-0">This item is fresh and doesn't have any hoarders yet! Come back later!</p>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
</div>
|
||||
<nav aria-label="Hoarders">
|
||||
<ul class="pagination justify-content-center">
|
||||
<li style="margin-top: auto; margin-bottom: auto;">
|
||||
<select class="form-select form-select-sm" style="height: 37px !important;" id="p+hoarders-min-copies">
|
||||
<option value="2">Min. 2+ Copies</option>
|
||||
<option value="3">Min. 3+ Copies</option>
|
||||
<option value="5">Min. 5+ Copies</option>
|
||||
<option value="10">Min. 10+ Copies</option>
|
||||
<option value="15">Min. 15+ Copies</option>
|
||||
<option value="35">Min. 35+ Copies</option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#!" id="p+hoarders-first-pg">«</a>
|
||||
</li>
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#!" tabindex="-1" id="p+hoarders-prev-pg">‹</a>
|
||||
</li>
|
||||
<li class="page-item active">
|
||||
<a class="page-link">
|
||||
<span class="visually-hidden">Page</span>
|
||||
<span id="p+hoarders-current-pg">1</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#!" id="p+hoarders-next-pg">›</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#!" id="p+hoarders-last-pg">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
`;
|
||||
<div class="col d-flex align-items-center">
|
||||
<div>
|
||||
<h6 class="mb-1">
|
||||
<a class="text-reset" href="/u/${x.user.username}">${x.user.username}</a>
|
||||
</h6>
|
||||
<small class="text-muted">${x.copies} Copies <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="#${x.serials.sort((a, b) => a - b).join(', #')}"></i></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
|
||||
<i class="fad fa-exchange-alt me-1"></i>
|
||||
<span class="d-none d-sm-inline">Trade</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
).join('') : `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body text-center py-5 text-muted">
|
||||
<h1 class="display-3"><i class="fa-solid fa-rectangle-history-circle-user"></i></h1>
|
||||
<h5> No hoarders </h5>
|
||||
<p class="mb-0">This item is fresh and doesn't have any hoarders yet! Come back later!</p>
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
</div>
|
||||
<nav aria-label="Hoarders">
|
||||
<ul class="pagination justify-content-center">
|
||||
<li style="margin-top: auto; margin-bottom: auto;">
|
||||
<select class="form-select form-select-sm" style="height: 37px !important;" id="p+hoarders-min-copies">
|
||||
<option value="2">Min. 2+ Copies</option>
|
||||
<option value="3">Min. 3+ Copies</option>
|
||||
<option value="5">Min. 5+ Copies</option>
|
||||
<option value="10">Min. 10+ Copies</option>
|
||||
<option value="15">Min. 15+ Copies</option>
|
||||
<option value="35">Min. 35+ Copies</option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#!" id="p+hoarders-first-pg">«</a>
|
||||
</li>
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#!" tabindex="-1" id="p+hoarders-prev-pg">‹</a>
|
||||
</li>
|
||||
<li class="page-item active">
|
||||
<a class="page-link">
|
||||
<span class="visually-hidden">Page</span>
|
||||
<span id="p+hoarders-current-pg">1</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#!" id="p+hoarders-next-pg">›</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#!" id="p+hoarders-last-pg">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<small class="text-muted text-center mt-1 mb-3 d-block" style="font-size: 0.7rem;">feature of Poly+</small>
|
||||
`;
|
||||
Utilities.InjectResource('registerTooltips');
|
||||
|
||||
const Container = document.getElementById('p+hoarders-container');
|
||||
|
|
@ -582,53 +581,47 @@ async function HoardersList(min, avatars) {
|
|||
Current.innerText = Page + 1;
|
||||
|
||||
if (Groups[Page] !== undefined) {
|
||||
Container.innerHTML = Groups[Page].map(
|
||||
(x) => `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
${
|
||||
avatars === true
|
||||
? `
|
||||
<div class="col-auto">
|
||||
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
|
||||
</div>
|
||||
`
|
||||
: ''
|
||||
Container.innerHTML = Groups[Page].map((x) => `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
${ avatars === true ? `
|
||||
<div class="col-auto">
|
||||
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
|
||||
</div>
|
||||
` : ''
|
||||
}
|
||||
<div class="col d-flex align-items-center">
|
||||
<div>
|
||||
<h6 class="mb-1">
|
||||
<a class="text-reset" href="/users/${x.user.id}">${x.user.username}</a>
|
||||
</h6>
|
||||
<small class="text-muted">${x.copies} Copies <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="#${x.serials.sort((a, b) => a - b).join(', #')}"></i></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
|
||||
<i class="fad fa-exchange-alt me-1"></i>
|
||||
<span class="d-none d-sm-inline">Trade</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
<div class="col d-flex align-items-center">
|
||||
<div>
|
||||
<h6 class="mb-1">
|
||||
<a class="text-reset" href="/users/${x.user.id}">${x.user.username}</a>
|
||||
</h6>
|
||||
<small class="text-muted">${x.copies} Copies <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="#${x.serials.sort((a, b) => a - b).join(', #')}"></i></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
|
||||
<i class="fad fa-exchange-alt me-1"></i>
|
||||
<span class="d-none d-sm-inline">Trade</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
).join('');
|
||||
|
||||
Utilities.InjectResource('registerTooltips');
|
||||
} else {
|
||||
Container.innerHTML = `
|
||||
<div class="card mb-3">
|
||||
<div class="card-body text-center py-5 text-muted">
|
||||
<h1 class="display-3"><i class="fa-solid fa-rectangle-history-circle-user"></i></h1>
|
||||
<h5> No hoarders </h5>
|
||||
<p class="mb-0">This item is fresh and doesn't have any hoarders yet! Come back later!</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
MinCopies.disabled = true;
|
||||
<div class="card mb-3">
|
||||
<div class="card-body text-center py-5 text-muted">
|
||||
<h1 class="display-3"><i class="fa-solid fa-rectangle-history-circle-user"></i></h1>
|
||||
<h5> No hoarders </h5>
|
||||
<p class="mb-0">This item is fresh and doesn't have any hoarders yet! Come back later!</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (Page > 0) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) {
|
|||
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
|
||||
Utilities = Utilities.default;
|
||||
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
Array.from(ItemGrid.children).forEach((element) => {
|
||||
LoadIRLPrices(element);
|
||||
});
|
||||
|
|
@ -59,7 +59,7 @@ const observer = new MutationObserver(async function (list) {
|
|||
for (const record of list) {
|
||||
for (const element of record.addedNodes) {
|
||||
if (element.tagName === 'DIV' && element.classList.value === 'mb-3 itemCardCont') {
|
||||
if (Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
LoadIRLPrices(element);
|
||||
}
|
||||
|
||||
|
|
|
|||
37
package-lock.json
generated
37
package-lock.json
generated
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
"name": "PolyPlus",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-jinja-template": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-plugin-jinja-template": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-jinja-template/-/prettier-plugin-jinja-template-1.4.0.tgz",
|
||||
"integrity": "sha512-9i7HwTAryhOTtY1ENyZBZA+KNaPphSaI/sXbQno5a6/DgiP6ZAnUiax4cOKiutEwiSDhVfLbTXEfHS5QAUVWBg==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"prettier": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"scripts": {
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-jinja-template": "^1.4.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -109,15 +109,15 @@ export default {
|
|||
TextureTypes: ['shirt', 'pants', 'face'],
|
||||
CalculateIRL: async function (bricks, to, brickPackage) {
|
||||
/*
|
||||
Disabled for now: currency retrieval from currencies.json
|
||||
Disabled for now: currency retrieval from currencies.json
|
||||
|
||||
const response = await fetch(chrome.runtime.getURL('resources/currencies.json'))
|
||||
if (!response.ok) {
|
||||
throw new Error('Getting currency data failure')
|
||||
}
|
||||
const data = await response.json()
|
||||
const UnitPrice = data.Data[brickPackage][to]
|
||||
*/
|
||||
const response = await fetch(chrome.runtime.getURL('resources/currencies.json'))
|
||||
if (!response.ok) {
|
||||
throw new Error('Getting currency data failure')
|
||||
}
|
||||
const data = await response.json()
|
||||
const UnitPrice = data.Data[brickPackage][to]
|
||||
*/
|
||||
|
||||
let Icon = '$';
|
||||
let Result = 'N/A';
|
||||
|
|
@ -212,10 +212,17 @@ export default {
|
|||
};
|
||||
},
|
||||
InjectResource: function (path, element) {
|
||||
// Function by devjin0617 on GitHub
|
||||
// Gist: https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a
|
||||
// Slightly modified to use constants and fit the rest of the code style more
|
||||
// Function only used for registering bootstrap tooltips currently
|
||||
/*
|
||||
Function by devjin0617 on GitHub
|
||||
Gist: https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a
|
||||
Slightly modified to use constants and fit the rest of the code style more
|
||||
Function only used for registering bootstrap tooltips and getting the signed-in user's username, user ID, and brick count currently
|
||||
*/
|
||||
|
||||
/*
|
||||
Potentially make this use chrome.runtime.sendMessage in the background.js script soon
|
||||
*/
|
||||
|
||||
|
||||
if (element === undefined) {
|
||||
element = 'body';
|
||||
|
|
|
|||
69
settings.js
69
settings.js
|
|
@ -1,6 +1,7 @@
|
|||
const SaveBtn = document.getElementById('Save');
|
||||
const Elements = Array.from(document.getElementsByClassName('setting-container'));
|
||||
|
||||
var RecentSave;
|
||||
var Settings;
|
||||
|
||||
var Utilities;
|
||||
|
|
@ -12,16 +13,14 @@ var Utilities;
|
|||
document.getElementById('PinnedGames-limit').innerText = Utilities.Limits.PinnedGames;
|
||||
document.getElementById('BestFriends-limit').innerText = Utilities.Limits.BestFriends;
|
||||
document.getElementById('ImprovedFrLists-limit').innerText = Utilities.Limits.ImprovedFrLists;
|
||||
document.getElementById('ItemWishlist-limit').innerText = Utilities.Limits.ItemWishlist;
|
||||
//document.getElementById('ItemWishlist-limit').innerText = Utilities.Limits.ItemWishlist;
|
||||
})();
|
||||
|
||||
// Handle buttons at the bottom of the page
|
||||
document.getElementById('ResetDefaults').addEventListener('click', function () {
|
||||
document.getElementById('ResetDefaults-Modal').showModal();
|
||||
});
|
||||
SaveBtn.addEventListener('click', function () {
|
||||
Save();
|
||||
});
|
||||
SaveBtn.addEventListener('click', Save);
|
||||
|
||||
// Handle modal buttons for Reset Defaults modal
|
||||
document.getElementById('ResetDefaults-Modal-Yes').addEventListener('click', function () {
|
||||
|
|
@ -36,16 +35,8 @@ document.getElementById('ResetDefaults-Modal-No').addEventListener('click', func
|
|||
document.getElementById('ResetDefaults-Modal').close();
|
||||
});
|
||||
|
||||
// Handle leaving the settings page before saving
|
||||
window.onbeforeunload = function () {
|
||||
if (SaveBtn.getAttribute('disabled') !== undefined) {
|
||||
return "Are you sure you'd like to leave? Your Poly+ settings haven't been saved.";
|
||||
}
|
||||
};
|
||||
|
||||
// Loop thru each setting container and handle toggling, selecting, opening modal, etc
|
||||
Elements.forEach((element) => {
|
||||
console.log('Handle Element', element);
|
||||
let Button = element.getElementsByTagName('button')[0];
|
||||
let Options = element.getElementsByTagName('button')[1];
|
||||
let Select = element.getElementsByTagName('select')[0];
|
||||
|
|
@ -93,16 +84,20 @@ Elements.forEach((element) => {
|
|||
if (Setting === '[save]') {
|
||||
// Save Modal Button
|
||||
|
||||
// Save Modal Inputs
|
||||
Array.from(ModalInputs)
|
||||
.filter((x) => !x.classList.contains('ignore'))
|
||||
.forEach((input) => {
|
||||
SetSetting(input, input.value, false, Modal.getAttribute('data-setting'));
|
||||
});
|
||||
|
||||
// Save Modal Select Menus
|
||||
Array.from(ModalSelect)
|
||||
.filter((x) => !x.classList.contains('ignore'))
|
||||
.forEach((select) => {
|
||||
SetSetting(select, select.selectedIndex, false, Modal.getAttribute('data-setting'));
|
||||
});
|
||||
|
||||
Save();
|
||||
setTimeout(function () {
|
||||
LoadCurrent();
|
||||
|
|
@ -156,17 +151,18 @@ Elements.forEach((element) => {
|
|||
function LoadCurrent() {
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
||||
Settings = MergeObjects(result.PolyPlus_Settings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
||||
RecentSave = structuredClone(Settings)
|
||||
|
||||
console.log('Current Settings: ', Settings);
|
||||
|
||||
Elements.forEach((element) => {
|
||||
console.log('For Each Update');
|
||||
UpdateElementState(element);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function SetSetting(element, value, update, modalParent) {
|
||||
document.title = '*unsaved | Poly+ Settings'
|
||||
const name = element.getAttribute('data-setting');
|
||||
let parent = element.getAttribute('data-parent');
|
||||
|
||||
|
|
@ -181,7 +177,6 @@ function SetSetting(element, value, update, modalParent) {
|
|||
if (parent !== null) {
|
||||
let Parent = Object.values(Settings)[Object.keys(Settings).indexOf(parent)];
|
||||
if (!isNaN(element.getAttribute('data-parent')) && element.getAttribute('data-parent') !== null) {
|
||||
console.log('is numbere!!!!');
|
||||
Parent = Parent[parseInt(element.getAttribute('data-parent'))];
|
||||
}
|
||||
Parent[name] = value;
|
||||
|
|
@ -193,11 +188,16 @@ function SetSetting(element, value, update, modalParent) {
|
|||
}
|
||||
if (SaveBtn.getAttribute('disabled')) {
|
||||
SaveBtn.removeAttribute('disabled');
|
||||
}
|
||||
|
||||
const getInObject = function (a, b) {
|
||||
return Object.values(a)[Object.keys(a).indexOf(b)];
|
||||
};
|
||||
// Handle leaving the settings page before saving
|
||||
window.onbeforeunload = function (e) {
|
||||
return "Are you sure you'd like to leave? Your Poly+ settings haven't been saved."
|
||||
};
|
||||
}
|
||||
if (AreIdentical(Settings, RecentSave) === true) {
|
||||
document.title = 'Poly+ Settings'
|
||||
SaveBtn.disabled = true
|
||||
}
|
||||
}
|
||||
|
||||
function GetSettingValue(element, modalParent) {
|
||||
|
|
@ -217,40 +217,31 @@ function GetSettingValue(element, modalParent) {
|
|||
} else {
|
||||
Status = Object.values(Parent)[Object.keys(Parent).indexOf(name)];
|
||||
}
|
||||
|
||||
/*
|
||||
if (!isNaN(element.getAttribute('data-parent'))) {
|
||||
Parent = Parent[parseInt(element.getAttribute('data-parent'))]
|
||||
}
|
||||
Status = Object.values(Parent)[Object.keys(Parent).indexOf(Status)]
|
||||
*/
|
||||
} else {
|
||||
Status = Settings[Status];
|
||||
}
|
||||
console.log('Get Value Result', Status);
|
||||
|
||||
if (element.tagName === 'SELECT' && element.getAttribute('data-useValue') === 'true') {
|
||||
Status = Array.from(element.children).indexOf(element.querySelector('option[value="' + Status + '"]'))
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
function UpdateElementState(element, status) {
|
||||
console.log('Update Element State', element, status);
|
||||
|
||||
const Button = element.getElementsByClassName('toggle-btn')[0];
|
||||
|
||||
if (status === undefined) {
|
||||
console.log('Update Element State, no status provided');
|
||||
status = GetSettingValue(Button);
|
||||
}
|
||||
|
||||
if (status === true) {
|
||||
console.log('Is Enabled so Set False');
|
||||
element.classList.add('enabled');
|
||||
element.classList.remove('disabled');
|
||||
Button.innerText = 'Disable';
|
||||
Button.classList.add('btn-danger');
|
||||
Button.classList.remove('btn-success');
|
||||
} else {
|
||||
console.log('Is Disabled so Set True');
|
||||
element.classList.add('disabled');
|
||||
element.classList.remove('enabled');
|
||||
Button.innerText = 'Enable';
|
||||
|
|
@ -260,15 +251,12 @@ function UpdateElementState(element, status) {
|
|||
|
||||
let SelectInput = element.getElementsByTagName('select')[0];
|
||||
if (SelectInput) {
|
||||
console.log('Select Found');
|
||||
SelectInput.selectedIndex = GetSettingValue(SelectInput);
|
||||
}
|
||||
|
||||
let Checkbox = Array.from(element.getElementsByTagName('input'));
|
||||
if (Checkbox.length > 0) {
|
||||
console.log('Checkbox/Input(s) Found', Checkbox);
|
||||
Checkbox.forEach((check) => {
|
||||
console.log('check', GetSettingValue(check));
|
||||
check.checked = GetSettingValue(check);
|
||||
});
|
||||
}
|
||||
|
|
@ -277,10 +265,14 @@ function UpdateElementState(element, status) {
|
|||
function Save() {
|
||||
document.title = 'Poly+ Settings';
|
||||
SaveBtn.setAttribute('disabled', 'true');
|
||||
chrome.storage.sync.set({PolyPlus_Settings: Settings, arrayOrder: true}, function () {
|
||||
chrome.storage.sync.set({PolyPlus_Settings: Settings}, function () {
|
||||
console.log('Saved successfully!');
|
||||
RecentSave = Settings
|
||||
});
|
||||
|
||||
// Handle leaving the settings page after saving
|
||||
window.onbeforeunload = null
|
||||
|
||||
console.log('Save:', Settings);
|
||||
}
|
||||
|
||||
|
|
@ -353,6 +345,11 @@ function MergeObjects(obj1, obj2) {
|
|||
return mergedObj;
|
||||
}
|
||||
|
||||
function AreIdentical(obj1, obj2) {
|
||||
if (obj1.length !== obj2.length) { return false }
|
||||
return JSON.stringify(obj1) === JSON.stringify(obj2)
|
||||
}
|
||||
|
||||
function FormatBool(bool) {
|
||||
if (bool === true) {
|
||||
return 'enabled';
|
||||
|
|
@ -397,6 +394,7 @@ function CheckForUpdates() {
|
|||
}
|
||||
CheckForUpdatesButton.addEventListener('click', CheckForUpdates);
|
||||
|
||||
/*
|
||||
fetch(chrome.runtime.getURL('resources/currencies.json'))
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
|
|
@ -411,6 +409,7 @@ fetch(chrome.runtime.getURL('resources/currencies.json'))
|
|||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
*/
|
||||
|
||||
chrome.storage.local.get(['PolyPlus_OutOfDate', 'PolyPlus_LiveVersion', 'PolyPlus_ReleaseNotes', 'PolyPlus_SkipUpdate'], function (result) {
|
||||
const OutOfDate = result.PolyPlus_OutOfDate || false;
|
||||
|
|
|
|||
Reference in a new issue