improvements and add missing feature parts
- You can no longer wish-list place achievements - Fixed IRL price and wish-listing game passes - Fixed the "Item Wishlist" feature link on the inventory page sidebar linking to the wish-list directory several times if clicked on several times - Fixed "owned" tags on the store main page only loading when the item grid updates, it now loads tags when initially loaded too - Fixed "Modify Navbar" feature navbar items being shifted and the "Forum" link unable to be edited - Added IRL prices to the "Game Passes" section of the place view page - Added IRL prices to the "Trending Items" section of the homepage - Updates to how the home.js file runs (going to rewrite it eventually) - Pinned Games now have a gradient overlay displaying the likes and dislikes above the place thumbnail
This commit is contained in:
parent
803de88fa0
commit
7cd6fb578b
7 changed files with 157 additions and 67 deletions
|
|
@ -1,13 +1,42 @@
|
||||||
|
/*
|
||||||
|
this file needs a rewrite by me lol
|
||||||
|
*/
|
||||||
|
|
||||||
var Settings;
|
var Settings;
|
||||||
var PinnedGames;
|
var PinnedGamesData
|
||||||
var BestFriends;
|
var BestFriendsData
|
||||||
|
|
||||||
|
chrome.storage.sync.get(['PolyPlus_Settings'], async function(result) {
|
||||||
|
Settings = result.PolyPlus_Settings || {}
|
||||||
|
|
||||||
|
if (Settings.IRLPriceWithCurrencyOn === true) {
|
||||||
|
IRLPrice()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.PinnedGamesOn === true || Settings.BestFriendsOn === true) {
|
||||||
|
Update()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let ContainerElement = `
|
let ContainerElement = `
|
||||||
<div class="card-body p-0 m-1 scrollFadeContainer d-flex"></div>`;
|
<div class="card-body p-0 m-1 scrollFadeContainer d-flex"></div>`;
|
||||||
let GameContainerElement = `
|
let GameContainerElement = `
|
||||||
<div class="scrollFade card me-2 place-card force-desktop text-center mb-2" style="opacity: 1;">
|
<div class="scrollFade card me-2 place-card force-desktop text-center mb-2" style="opacity: 1;">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<img src=":Thumbnail" class="place-card-image">
|
<div class="ratings-header">
|
||||||
|
<img src=":Thumbnail" class="place-card-image" style="position: relative;">
|
||||||
|
<div style="position: absolute;background: linear-gradient(to bottom, black, transparent, transparent, transparent);width: 100%;height: 100%;top: 0;left: 0;border-radius: 10px;padding-top: 5px;">
|
||||||
|
<span>
|
||||||
|
<i id="thumbup-icn" class="thumb-icon far fa-thumbs-up"></i>
|
||||||
|
:Likes
|
||||||
|
</span>
|
||||||
|
|
|
||||||
|
<span>
|
||||||
|
<i id="thumbdown-icn" class="thumb-icon far fa-thumbs-down"></i>
|
||||||
|
:Dislikes
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="mt-2 mb-1 place-card-title">
|
<div class="mt-2 mb-1 place-card-title">
|
||||||
:GameName
|
:GameName
|
||||||
|
|
@ -37,13 +66,6 @@ NewTitle.innerHTML = TitleElement;
|
||||||
let BestFriendsContainer = document.createElement('div')
|
let BestFriendsContainer = document.createElement('div')
|
||||||
BestFriendsContainer.classList = 'd-flex'
|
BestFriendsContainer.classList = 'd-flex'
|
||||||
BestFriendsContainer.style = 'display: none; border-bottom: 1px solid #000; padding-bottom: 10px; margin-bottom: 10px; width: 100%;'
|
BestFriendsContainer.style = 'display: none; border-bottom: 1px solid #000; padding-bottom: 10px; margin-bottom: 10px; width: 100%;'
|
||||||
/*
|
|
||||||
BestFriendsContainer.style.display = 'none'
|
|
||||||
BestFriendsContainer.style.borderBottom = '1px solid #000'
|
|
||||||
BestFriendsContainer.style.paddingBottom = '10px'
|
|
||||||
BestFriendsContainer.style.marginBottom = '10px'
|
|
||||||
BestFriendsContainer.style.width = '100%'
|
|
||||||
*/
|
|
||||||
|
|
||||||
let Spacer = document.createElement('div')
|
let Spacer = document.createElement('div')
|
||||||
Spacer.innerHTML = ' '
|
Spacer.innerHTML = ' '
|
||||||
|
|
@ -51,40 +73,38 @@ Spacer.style.width = '50px'
|
||||||
Spacer.prepend(BestFriendsContainer)
|
Spacer.prepend(BestFriendsContainer)
|
||||||
|
|
||||||
FriendContainer.prepend(BestFriendsContainer)
|
FriendContainer.prepend(BestFriendsContainer)
|
||||||
UpdateLocalData();
|
|
||||||
|
|
||||||
function UpdateLocalData() {
|
async function Update() {
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
|
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
||||||
Settings = result.PolyPlus_Settings || {PinnedGamesOn: true, BestFriendsOn: false}
|
PinnedGamesData = result.PolyPlus_PinnedGames || [];
|
||||||
|
|
||||||
|
if (Settings.PinnedGamesOn === true) {
|
||||||
|
PinnedGames()
|
||||||
|
} else {
|
||||||
|
NewContainer.style.display = 'none'
|
||||||
|
NewTitle.style.display = 'none'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) {
|
||||||
PinnedGames = result.PolyPlus_PinnedGames || [];
|
BestFriendsData = result.PolyPlus_BestFriends || [];
|
||||||
chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) {
|
|
||||||
BestFriends = result.PolyPlus_BestFriends || [];
|
if (Settings.BestFriendsOn === true) {
|
||||||
if (Settings.PinnedGamesOn === true) {
|
BestFriends();
|
||||||
LoadPinnedGames();
|
} else {
|
||||||
} else {
|
BestFriendsContainer.style.display = 'none'
|
||||||
NewContainer.style.display = 'none'
|
Spacer.style.display = 'none'
|
||||||
NewTitle.style.display = 'none'
|
}
|
||||||
}
|
|
||||||
if (Settings.BestFriendsOn === true) {
|
|
||||||
LoadBestFriends();
|
|
||||||
} else {
|
|
||||||
BestFriendsContainer.style.display = 'none'
|
|
||||||
Spacer.style.display = 'none'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadPinnedGames() {
|
function PinnedGames() {
|
||||||
var Existing = NewContainer.children[0].children
|
var Existing = NewContainer.children[0].children
|
||||||
Array.from(Existing).forEach(element => {
|
Array.from(Existing).forEach(element => {
|
||||||
element.remove();
|
element.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (PinnedGames.length === 0) {
|
if (PinnedGamesData.length === 0) {
|
||||||
NewContainer.style.display = 'none'
|
NewContainer.style.display = 'none'
|
||||||
NewTitle.style.display = 'none'
|
NewTitle.style.display = 'none'
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -92,7 +112,7 @@ function LoadPinnedGames() {
|
||||||
NewTitle.style.display = ''
|
NewTitle.style.display = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
PinnedGames.forEach(element => {
|
PinnedGamesData.forEach(element => {
|
||||||
fetch('https://api.polytoria.com/v1/places/' + element)
|
fetch('https://api.polytoria.com/v1/places/' + element)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
@ -100,12 +120,14 @@ function LoadPinnedGames() {
|
||||||
let GameThumbnail = data.thumbnail;
|
let GameThumbnail = data.thumbnail;
|
||||||
|
|
||||||
var NewGameContainer = document.createElement('a');
|
var NewGameContainer = document.createElement('a');
|
||||||
NewGameContainer.innerHTML = GameContainerElement.replace(':GameName',GameName).replace(':Thumbnail',GameThumbnail);
|
NewGameContainer.innerHTML = GameContainerElement.replace(':GameName',GameName).replace(':Thumbnail',GameThumbnail).replace(':Likes', data.rating.likes).replace(':Dislikes', data.rating.dislikes);
|
||||||
NewGameContainer.setAttribute('href', '/places/' + element);
|
NewGameContainer.href = '/places/' + element
|
||||||
|
|
||||||
|
/*
|
||||||
if (new Date().getDate() >= new Date(data.updatedAt).getDate()) {
|
if (new Date().getDate() >= new Date(data.updatedAt).getDate()) {
|
||||||
console.log('Game has updated')
|
console.log('Game has updated')
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
NewContainer.children[0].appendChild(NewGameContainer);
|
NewContainer.children[0].appendChild(NewGameContainer);
|
||||||
})
|
})
|
||||||
|
|
@ -115,14 +137,14 @@ function LoadPinnedGames() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadBestFriends() {
|
function BestFriends() {
|
||||||
Array.from(document.querySelectorAll('[bestFriend]')).forEach(element => {
|
Array.from(document.querySelectorAll('[bestFriend]')).forEach(element => {
|
||||||
element.removeAttribute('bestFriend')
|
element.removeAttribute('bestFriend')
|
||||||
element.getElementsByClassName('friend-name')[0].style.color = 'initial';
|
element.getElementsByClassName('friend-name')[0].style.color = 'initial';
|
||||||
FriendContainer.appendChild(element)
|
FriendContainer.appendChild(element)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (BestFriends.length === 0) {
|
if (BestFriendsData.length === 0) {
|
||||||
BestFriendsContainer.style.visibility = 'hidden'
|
BestFriendsContainer.style.visibility = 'hidden'
|
||||||
BestFriendsContainer.style.padding = '0px !important'
|
BestFriendsContainer.style.padding = '0px !important'
|
||||||
BestFriendsContainer.style.margin = '0px !important'
|
BestFriendsContainer.style.margin = '0px !important'
|
||||||
|
|
@ -132,7 +154,7 @@ function LoadBestFriends() {
|
||||||
BestFriendsContainer.style.margin = ''
|
BestFriendsContainer.style.margin = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
BestFriends.forEach(element => {
|
BestFriendsData.forEach(element => {
|
||||||
let ExistingFriend = document.getElementById('friend-' + element)
|
let ExistingFriend = document.getElementById('friend-' + element)
|
||||||
if (ExistingFriend) {
|
if (ExistingFriend) {
|
||||||
ExistingFriend.setAttribute('bestFriend', 'true')
|
ExistingFriend.setAttribute('bestFriend', 'true')
|
||||||
|
|
@ -145,3 +167,24 @@ function LoadBestFriends() {
|
||||||
var SecondaryColumn = document.getElementsByClassName('col-lg-8')[0]
|
var SecondaryColumn = document.getElementsByClassName('col-lg-8')[0]
|
||||||
SecondaryColumn.insertBefore(NewContainer, SecondaryColumn.children[0]);
|
SecondaryColumn.insertBefore(NewContainer, SecondaryColumn.children[0]);
|
||||||
SecondaryColumn.insertBefore(NewTitle, SecondaryColumn.children[0]);
|
SecondaryColumn.insertBefore(NewTitle, SecondaryColumn.children[0]);
|
||||||
|
|
||||||
|
async function IRLPrice() {
|
||||||
|
(async () => {
|
||||||
|
let Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
|
||||||
|
const TrendingItems = document.getElementById('home-trendingItems')
|
||||||
|
console.log(TrendingItems.children[1].getElementsByClassName('d-flex')[0].children)
|
||||||
|
for (let item of TrendingItems.children[1].getElementsByClassName('d-flex')[0].children) {
|
||||||
|
const Price = item.getElementsByClassName('text-success')[0]
|
||||||
|
console.log(item, Price)
|
||||||
|
const Result = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrencyCurrency)
|
||||||
|
|
||||||
|
let Span = document.createElement('span')
|
||||||
|
Span.classList = 'text-muted polyplus-price-tag'
|
||||||
|
Span.style.fontSize = '0.7rem'
|
||||||
|
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||||
|
Price.appendChild(Span)
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ if (window.location.pathname.split('/')[3] === "inventory") {
|
||||||
let WishlistNav = document.createElement('li')
|
let WishlistNav = document.createElement('li')
|
||||||
WishlistNav.classList.add('nav-item')
|
WishlistNav.classList.add('nav-item')
|
||||||
WishlistNav.innerHTML = `
|
WishlistNav.innerHTML = `
|
||||||
<a href="wishlist/" class="nav-link">
|
<a href="/users/${UserID}/inventory/wishlist/" class="nav-link">
|
||||||
<i class="fa-regular fa-sparkles me-1"></i>
|
<i class="fa-regular fa-sparkles me-1"></i>
|
||||||
<span class="pilltitle">Item Wishlist</span>
|
<span class="pilltitle">Item Wishlist</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ let Theme = null;
|
||||||
|
|
||||||
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
|
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
|
||||||
let NavbarItems = document.querySelectorAll('.navbar-nav.me-auto a.nav-link[href]')
|
let NavbarItems = document.querySelectorAll('.navbar-nav.me-auto a.nav-link[href]')
|
||||||
let Needed = [NavbarItems[10],NavbarItems[11],NavbarItems[12],NavbarItems[13],NavbarItems[14]]
|
let Needed = [NavbarItems[11],NavbarItems[12],NavbarItems[13],NavbarItems[14],NavbarItems[15]]
|
||||||
for (let i = 0; i < Settings.ModifyNav.length; i++) {
|
for (let i = 0; i < Settings.ModifyNav.length; i++) {
|
||||||
if (Settings.ModifyNav[i].Label != null) {
|
if (Settings.ModifyNav[i].Label != null) {
|
||||||
console.log(Needed[i], Needed[i].children[1])
|
console.log(Needed[i], Needed[i].children[1])
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,11 @@ switch (Type) {
|
||||||
case 'places':
|
case 'places':
|
||||||
CreatorID = document.querySelector('.mcard .col .text-muted [href^="/users/"]').getAttribute('href').split('/')[2]
|
CreatorID = document.querySelector('.mcard .col .text-muted [href^="/users/"]').getAttribute('href').split('/')[2]
|
||||||
break
|
break
|
||||||
|
/*
|
||||||
case 'feed':
|
case 'feed':
|
||||||
CreatorID = document.querySelector('p a[href^="/users/"].text-reset').getAttribute('href').split('/')[2]
|
CreatorID = document.querySelector('p a[href^="/users/"].text-reset').getAttribute('href').split('/')[2]
|
||||||
break
|
break
|
||||||
|
*/
|
||||||
case 'guilds':
|
case 'guilds':
|
||||||
CreatorID = document.querySelector('[class^="userlink-"][href^="/users/"]').getAttribute('href').split('/')[2]
|
CreatorID = document.querySelector('[class^="userlink-"][href^="/users/"]').getAttribute('href').split('/')[2]
|
||||||
Comments = document.getElementById('wall-posts')
|
Comments = document.getElementById('wall-posts')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
const GameID = window.location.pathname.split('/')[2]
|
const GameID = window.location.pathname.split('/')[2]
|
||||||
|
|
||||||
|
let Utilities;
|
||||||
|
|
||||||
var Settings;
|
var Settings;
|
||||||
var PinnedGames;
|
var PinnedGamesData = []
|
||||||
let GamePinned;
|
let GamePinned;
|
||||||
|
|
||||||
!(() => {
|
!(() => {
|
||||||
|
|
@ -30,7 +32,7 @@ let GamePinned;
|
||||||
|
|
||||||
RatingsContainer.children[0].appendChild(PercentageLabel)
|
RatingsContainer.children[0].appendChild(PercentageLabel)
|
||||||
|
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
|
chrome.storage.sync.get(['PolyPlus_Settings'], async function(result) {
|
||||||
Settings = result.PolyPlus_Settings || {}
|
Settings = result.PolyPlus_Settings || {}
|
||||||
|
|
||||||
if (Settings.PinnedGamesOn === true) {
|
if (Settings.PinnedGamesOn === true) {
|
||||||
|
|
@ -46,18 +48,31 @@ let GamePinned;
|
||||||
if (Settings.GameProfilesOn === true) {
|
if (Settings.GameProfilesOn === true) {
|
||||||
GameProfiles()
|
GameProfiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Settings.IRLPriceWithCurrencyOn === true) {
|
||||||
|
(async () => {
|
||||||
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
|
||||||
|
IRLPrice()
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.StoreOwnTagsOn === true) {
|
||||||
|
OwnedTags()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})()
|
})()
|
||||||
|
|
||||||
async function PinnedGames() {
|
async function PinnedGames() {
|
||||||
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
|
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
|
||||||
PinnedGames = result.PolyPlus_PinnedGames || {};
|
PinnedGamesData = result.PolyPlus_PinnedGames || [];
|
||||||
/*
|
/*
|
||||||
const PinBtn = document.createElement('button');
|
const PinBtn = document.createElement('button');
|
||||||
PinBtn.classList = 'btn btn-warning btn-sm';
|
PinBtn.classList = 'btn btn-warning btn-sm';
|
||||||
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
|
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
|
||||||
|
|
||||||
if (PinnedGames[GameID]) {
|
if (PinnedGamesData[GameID]) {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin';
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin';
|
||||||
} else {
|
} else {
|
||||||
if (PinnedGames.length !== 5) {
|
if (PinnedGames.length !== 5) {
|
||||||
|
|
@ -72,10 +87,10 @@ async function PinnedGames() {
|
||||||
PinBtn.classList = 'btn btn-warning btn-sm';
|
PinBtn.classList = 'btn btn-warning btn-sm';
|
||||||
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
|
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
|
||||||
|
|
||||||
if (PinnedGames.includes(parseInt(GameID))) {
|
if (PinnedGamesData.includes(parseInt(GameID))) {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin';
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin';
|
||||||
} else {
|
} else {
|
||||||
if (PinnedGames.length !== 5) {
|
if (PinnedGamesData.length !== 5) {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
||||||
} else {
|
} else {
|
||||||
PinBtn.setAttribute('disabled', true)
|
PinBtn.setAttribute('disabled', true)
|
||||||
|
|
@ -87,7 +102,7 @@ async function PinnedGames() {
|
||||||
PinBtn.setAttribute('disabled', 'true')
|
PinBtn.setAttribute('disabled', 'true')
|
||||||
|
|
||||||
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
||||||
PinnedGames = result.PolyPlus_PinnedGames || [];
|
PinnedGamesData = result.PolyPlus_PinnedGames || [];
|
||||||
/*
|
/*
|
||||||
const Index = PinnedGames.indexOf(parseInt(GameID))
|
const Index = PinnedGames.indexOf(parseInt(GameID))
|
||||||
if (Index !== -1) {
|
if (Index !== -1) {
|
||||||
|
|
@ -100,19 +115,19 @@ async function PinnedGames() {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const Index = PinnedGames.indexOf(parseInt(GameID));
|
const Index = PinnedGamesData.indexOf(parseInt(GameID));
|
||||||
if (Index !== -1) {
|
if (Index !== -1) {
|
||||||
PinnedGames.splice(Index, 1);
|
PinnedGamesData.splice(Index, 1);
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
||||||
} else {
|
} else {
|
||||||
PinnedGames.push(parseInt(GameID));
|
PinnedGamesData.push(parseInt(GameID));
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.storage.sync.set({ 'PolyPlus_PinnedGames': PinnedGames, arrayOrder: true }, function() {
|
chrome.storage.sync.set({ 'PolyPlus_PinnedGames': PinnedGamesData, arrayOrder: true }, function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
PinBtn.removeAttribute('disabled')
|
PinBtn.removeAttribute('disabled')
|
||||||
console.log(PinnedGames)
|
console.log(PinnedGamesData)
|
||||||
}, 1250)
|
}, 1250)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -123,13 +138,13 @@ async function PinnedGames() {
|
||||||
chrome.storage.onChanged.addListener(function(changes, namespace) {
|
chrome.storage.onChanged.addListener(function(changes, namespace) {
|
||||||
if ('PolyPlus_PinnedGames' in changes) {
|
if ('PolyPlus_PinnedGames' in changes) {
|
||||||
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
|
||||||
PinnedGames = result.PolyPlus_PinnedGames || [];
|
PinnedGamesData = result.PolyPlus_PinnedGames || [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (PinnedGames[GameID]) {
|
if (PinnedGamesData[GameID]) {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
||||||
} else {
|
} else {
|
||||||
if (PinnedGames.length !== 5) {
|
if (PinnedGamesData.length !== 5) {
|
||||||
PinBtn.removeAttribute('disabled')
|
PinBtn.removeAttribute('disabled')
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -138,10 +153,10 @@ async function PinnedGames() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (PinnedGames.includes(parseInt(GameID))) {
|
if (PinnedGamesData.includes(parseInt(GameID))) {
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
|
||||||
} else {
|
} else {
|
||||||
if (PinnedGames.length !== 5) {
|
if (PinnedGamesData.length !== 5) {
|
||||||
PinBtn.removeAttribute('disabled')
|
PinBtn.removeAttribute('disabled')
|
||||||
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -162,8 +177,6 @@ async function InlineEditing() {
|
||||||
// Improve editing visuals overall
|
// Improve editing visuals overall
|
||||||
|
|
||||||
const GameCreator = document.querySelector('#main-content .card-body .col div.text-muted a[href^="/users/"]').getAttribute('href').split('/')[2]
|
const GameCreator = document.querySelector('#main-content .card-body .col div.text-muted a[href^="/users/"]').getAttribute('href').split('/')[2]
|
||||||
console.log(GameCreator)
|
|
||||||
console.log(JSON.parse(window.localStorage.getItem('account_info')).ID)
|
|
||||||
if (GameCreator !== JSON.parse(window.localStorage.getItem('account_info')).ID) {
|
if (GameCreator !== JSON.parse(window.localStorage.getItem('account_info')).ID) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -360,3 +373,25 @@ async function GameProfiles(data) {
|
||||||
`
|
`
|
||||||
document.body.appendChild(Style)
|
document.body.appendChild(Style)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function IRLPrice() {
|
||||||
|
const Gamepasses = document.querySelector('#gamepasses-tabpane .row.flex-row').children
|
||||||
|
for (let gamepass of Gamepasses) {
|
||||||
|
const Price = gamepass.getElementsByClassName('text-success')[0]
|
||||||
|
const Result = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrencyCurrency)
|
||||||
|
|
||||||
|
let Span = document.createElement('span')
|
||||||
|
Span.classList = 'text-muted polyplus-price-tag'
|
||||||
|
Span.style.fontSize = '0.7rem'
|
||||||
|
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||||
|
Price.appendChild(Span)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function OwnedTags() {
|
||||||
|
const Gamepasses = document.querySelector('#gamepasses-tabpane .row.flex-row').children
|
||||||
|
for (let gamepass of Gamepasses) {
|
||||||
|
const GamePassID = gamepass.getElementsByTagName('a')[0].getAttribute('href').split('/')
|
||||||
|
console.log(GamePassID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const ItemID = window.location.pathname.split('/')[2]
|
const ItemID = window.location.pathname.split('/')[2]
|
||||||
|
const ItemType = document.querySelector('.col-12 .badge').innerHTML
|
||||||
|
|
||||||
var Utilities;
|
var Utilities;
|
||||||
|
|
||||||
|
|
@ -9,7 +10,7 @@ var WishlistBtn;
|
||||||
var ItemOwned;
|
var ItemOwned;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!(window.location.href.split('/')[4])) {return}
|
if (!(window.location.href.split('/')[4]) || ItemType === "achievement") {return}
|
||||||
|
|
||||||
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
Utilities = Utilities.default
|
Utilities = Utilities.default
|
||||||
|
|
@ -17,9 +18,12 @@ var ItemOwned;
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||||
Settings = result.PolyPlus_Settings || {}
|
Settings = result.PolyPlus_Settings || {}
|
||||||
PurchaseBtn = document.querySelector('.btn#purchase-button')
|
PurchaseBtn = document.querySelector('.btn#purchase-button')
|
||||||
|
if (ItemType === "gamePass") {
|
||||||
|
PurchaseBtn = document.querySelector('.btn.btn-outline-success[onclick^="buyAsset"]')
|
||||||
|
}
|
||||||
ItemOwned = (PurchaseBtn.innerText === ' Item owned' || document.querySelector('.btn[onclick="sellItem()"]') !== null)
|
ItemOwned = (PurchaseBtn.innerText === ' Item owned' || document.querySelector('.btn[onclick="sellItem()"]') !== null)
|
||||||
|
|
||||||
if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
|
if (Settings.IRLPriceWithCurrencyOn === true) { IRLPrice() }
|
||||||
|
|
||||||
if (Settings.ItemWishlistOn === true) {
|
if (Settings.ItemWishlistOn === true) {
|
||||||
HandleItemWishlist()
|
HandleItemWishlist()
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,16 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||||
});
|
});
|
||||||
|
|
||||||
function Update() {
|
function Update() {
|
||||||
console.log('update')
|
|
||||||
if (Settings.IRLPriceWithCurrencyOn === true) {
|
if (Settings.IRLPriceWithCurrencyOn === true) {
|
||||||
Array.from(ItemGrid.children).forEach(element => {LoadIRLPrices(element)});
|
Array.from(ItemGrid.children).forEach(element => {
|
||||||
|
LoadIRLPrices(element)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.StoreOwnTagOn === true) {
|
||||||
|
Array.from(ItemGrid.children).forEach(element => {
|
||||||
|
LoadOwnedTags(element)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,12 +67,11 @@ const observer = new MutationObserver(async function (list){
|
||||||
observer.observe(ItemGrid, {attributes: false,childList: true,subtree: false});
|
observer.observe(ItemGrid, {attributes: false,childList: true,subtree: false});
|
||||||
|
|
||||||
async function LoadIRLPrices(element) {
|
async function LoadIRLPrices(element) {
|
||||||
console.log('LOAD IRL PRICES!!!')
|
|
||||||
if (element.tagName != "DIV") {return}
|
if (element.tagName != "DIV") {return}
|
||||||
if (element.querySelector('small.text-primary')) {return}
|
if (element.querySelector('small.text-primary')) {return}
|
||||||
const Parent = element.getElementsByTagName('small')[1]
|
const Parent = element.getElementsByTagName('small')[1]
|
||||||
if (Parent.innerText === "") { return }
|
if (Parent.innerText === "") { return }
|
||||||
let Span = document.createElement('span')
|
const Span = document.createElement('span')
|
||||||
Span.classList = 'text-muted polyplus-price-tag'
|
Span.classList = 'text-muted polyplus-price-tag'
|
||||||
Span.style.fontSize = '0.7rem'
|
Span.style.fontSize = '0.7rem'
|
||||||
const Price = Parent.innerText
|
const Price = Parent.innerText
|
||||||
|
|
|
||||||
Reference in a new issue