:GameName
@@ -37,13 +66,6 @@ NewTitle.innerHTML = TitleElement;
let BestFriendsContainer = document.createElement('div')
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'
-BestFriendsContainer.style.borderBottom = '1px solid #000'
-BestFriendsContainer.style.paddingBottom = '10px'
-BestFriendsContainer.style.marginBottom = '10px'
-BestFriendsContainer.style.width = '100%'
-*/
let Spacer = document.createElement('div')
Spacer.innerHTML = ' '
@@ -51,40 +73,38 @@ Spacer.style.width = '50px'
Spacer.prepend(BestFriendsContainer)
FriendContainer.prepend(BestFriendsContainer)
-UpdateLocalData();
-function UpdateLocalData() {
- chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
- Settings = result.PolyPlus_Settings || {PinnedGamesOn: true, BestFriendsOn: false}
+async function Update() {
+ chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
+ 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) {
- PinnedGames = result.PolyPlus_PinnedGames || [];
- chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) {
- BestFriends = result.PolyPlus_BestFriends || [];
- if (Settings.PinnedGamesOn === true) {
- LoadPinnedGames();
- } else {
- NewContainer.style.display = 'none'
- NewTitle.style.display = 'none'
- }
- if (Settings.BestFriendsOn === true) {
- LoadBestFriends();
- } else {
- BestFriendsContainer.style.display = 'none'
- Spacer.style.display = 'none'
- }
- });
+ chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) {
+ BestFriendsData = result.PolyPlus_BestFriends || [];
+
+ if (Settings.BestFriendsOn === true) {
+ BestFriends();
+ } else {
+ BestFriendsContainer.style.display = 'none'
+ Spacer.style.display = 'none'
+ }
});
}
-function LoadPinnedGames() {
+function PinnedGames() {
var Existing = NewContainer.children[0].children
Array.from(Existing).forEach(element => {
element.remove();
});
- if (PinnedGames.length === 0) {
+ if (PinnedGamesData.length === 0) {
NewContainer.style.display = 'none'
NewTitle.style.display = 'none'
} else {
@@ -92,7 +112,7 @@ function LoadPinnedGames() {
NewTitle.style.display = ''
}
- PinnedGames.forEach(element => {
+ PinnedGamesData.forEach(element => {
fetch('https://api.polytoria.com/v1/places/' + element)
.then(response => response.json())
.then(data => {
@@ -100,12 +120,14 @@ function LoadPinnedGames() {
let GameThumbnail = data.thumbnail;
var NewGameContainer = document.createElement('a');
- NewGameContainer.innerHTML = GameContainerElement.replace(':GameName',GameName).replace(':Thumbnail',GameThumbnail);
- NewGameContainer.setAttribute('href', '/places/' + element);
+ NewGameContainer.innerHTML = GameContainerElement.replace(':GameName',GameName).replace(':Thumbnail',GameThumbnail).replace(':Likes', data.rating.likes).replace(':Dislikes', data.rating.dislikes);
+ NewGameContainer.href = '/places/' + element
+ /*
if (new Date().getDate() >= new Date(data.updatedAt).getDate()) {
console.log('Game has updated')
}
+ */
NewContainer.children[0].appendChild(NewGameContainer);
})
@@ -115,14 +137,14 @@ function LoadPinnedGames() {
});
}
-function LoadBestFriends() {
+function BestFriends() {
Array.from(document.querySelectorAll('[bestFriend]')).forEach(element => {
element.removeAttribute('bestFriend')
element.getElementsByClassName('friend-name')[0].style.color = 'initial';
FriendContainer.appendChild(element)
});
- if (BestFriends.length === 0) {
+ if (BestFriendsData.length === 0) {
BestFriendsContainer.style.visibility = 'hidden'
BestFriendsContainer.style.padding = '0px !important'
BestFriendsContainer.style.margin = '0px !important'
@@ -132,7 +154,7 @@ function LoadBestFriends() {
BestFriendsContainer.style.margin = ''
}
- BestFriends.forEach(element => {
+ BestFriendsData.forEach(element => {
let ExistingFriend = document.getElementById('friend-' + element)
if (ExistingFriend) {
ExistingFriend.setAttribute('bestFriend', 'true')
@@ -144,4 +166,25 @@ function LoadBestFriends() {
var SecondaryColumn = document.getElementsByClassName('col-lg-8')[0]
SecondaryColumn.insertBefore(NewContainer, SecondaryColumn.children[0]);
-SecondaryColumn.insertBefore(NewTitle, SecondaryColumn.children[0]);
\ No newline at end of file
+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)
+ }
+ })();
+}
\ No newline at end of file
diff --git a/js/account/inventory.js b/js/account/inventory.js
index e394c05..51be6ca 100755
--- a/js/account/inventory.js
+++ b/js/account/inventory.js
@@ -5,7 +5,7 @@ if (window.location.pathname.split('/')[3] === "inventory") {
let WishlistNav = document.createElement('li')
WishlistNav.classList.add('nav-item')
WishlistNav.innerHTML = `
-
+
Item Wishlist
diff --git a/js/everywhere.js b/js/everywhere.js
index 7b1fb46..613ca6e 100755
--- a/js/everywhere.js
+++ b/js/everywhere.js
@@ -149,7 +149,7 @@ let Theme = null;
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
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++) {
if (Settings.ModifyNav[i].Label != null) {
console.log(Needed[i], Needed[i].children[1])
diff --git a/js/op-comments.js b/js/op-comments.js
index 91a148c..053f93d 100755
--- a/js/op-comments.js
+++ b/js/op-comments.js
@@ -11,9 +11,11 @@ switch (Type) {
case 'places':
CreatorID = document.querySelector('.mcard .col .text-muted [href^="/users/"]').getAttribute('href').split('/')[2]
break
+ /*
case 'feed':
CreatorID = document.querySelector('p a[href^="/users/"].text-reset').getAttribute('href').split('/')[2]
break
+ */
case 'guilds':
CreatorID = document.querySelector('[class^="userlink-"][href^="/users/"]').getAttribute('href').split('/')[2]
Comments = document.getElementById('wall-posts')
diff --git a/js/places/place-view.js b/js/places/place-view.js
index 5a71d8d..5db372c 100644
--- a/js/places/place-view.js
+++ b/js/places/place-view.js
@@ -1,7 +1,9 @@
const GameID = window.location.pathname.split('/')[2]
+let Utilities;
+
var Settings;
-var PinnedGames;
+var PinnedGamesData = []
let GamePinned;
!(() => {
@@ -30,7 +32,7 @@ let GamePinned;
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 || {}
if (Settings.PinnedGamesOn === true) {
@@ -46,18 +48,31 @@ let GamePinned;
if (Settings.GameProfilesOn === true) {
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() {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
- PinnedGames = result.PolyPlus_PinnedGames || {};
+ PinnedGamesData = result.PolyPlus_PinnedGames || [];
/*
const PinBtn = document.createElement('button');
PinBtn.classList = 'btn btn-warning btn-sm';
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
- if (PinnedGames[GameID]) {
+ if (PinnedGamesData[GameID]) {
PinBtn.innerHTML = '
Un-pin';
} else {
if (PinnedGames.length !== 5) {
@@ -72,10 +87,10 @@ async function PinnedGames() {
PinBtn.classList = 'btn btn-warning btn-sm';
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
- if (PinnedGames.includes(parseInt(GameID))) {
+ if (PinnedGamesData.includes(parseInt(GameID))) {
PinBtn.innerHTML = '
Un-pin';
} else {
- if (PinnedGames.length !== 5) {
+ if (PinnedGamesData.length !== 5) {
PinBtn.innerHTML = '
Pin'
} else {
PinBtn.setAttribute('disabled', true)
@@ -87,7 +102,7 @@ async function PinnedGames() {
PinBtn.setAttribute('disabled', 'true')
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
- PinnedGames = result.PolyPlus_PinnedGames || [];
+ PinnedGamesData = result.PolyPlus_PinnedGames || [];
/*
const Index = PinnedGames.indexOf(parseInt(GameID))
if (Index !== -1) {
@@ -100,19 +115,19 @@ async function PinnedGames() {
PinBtn.innerHTML = '
Un-pin'
}
*/
- const Index = PinnedGames.indexOf(parseInt(GameID));
+ const Index = PinnedGamesData.indexOf(parseInt(GameID));
if (Index !== -1) {
- PinnedGames.splice(Index, 1);
+ PinnedGamesData.splice(Index, 1);
PinBtn.innerHTML = '
Pin'
} else {
- PinnedGames.push(parseInt(GameID));
+ PinnedGamesData.push(parseInt(GameID));
PinBtn.innerHTML = '
Un-pin'
}
- chrome.storage.sync.set({ 'PolyPlus_PinnedGames': PinnedGames, arrayOrder: true }, function() {
+ chrome.storage.sync.set({ 'PolyPlus_PinnedGames': PinnedGamesData, arrayOrder: true }, function() {
setTimeout(function() {
PinBtn.removeAttribute('disabled')
- console.log(PinnedGames)
+ console.log(PinnedGamesData)
}, 1250)
});
});
@@ -123,13 +138,13 @@ async function PinnedGames() {
chrome.storage.onChanged.addListener(function(changes, namespace) {
if ('PolyPlus_PinnedGames' in changes) {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
- PinnedGames = result.PolyPlus_PinnedGames || [];
+ PinnedGamesData = result.PolyPlus_PinnedGames || [];
/*
- if (PinnedGames[GameID]) {
+ if (PinnedGamesData[GameID]) {
PinBtn.innerHTML = '
Un-pin'
} else {
- if (PinnedGames.length !== 5) {
+ if (PinnedGamesData.length !== 5) {
PinBtn.removeAttribute('disabled')
PinBtn.innerHTML = '
Pin'
} else {
@@ -138,10 +153,10 @@ async function PinnedGames() {
}
}
*/
- if (PinnedGames.includes(parseInt(GameID))) {
+ if (PinnedGamesData.includes(parseInt(GameID))) {
PinBtn.innerHTML = '
Un-pin'
} else {
- if (PinnedGames.length !== 5) {
+ if (PinnedGamesData.length !== 5) {
PinBtn.removeAttribute('disabled')
PinBtn.innerHTML = '
Pin'
} else {
@@ -162,8 +177,6 @@ async function InlineEditing() {
// Improve editing visuals overall
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) {
return
}
@@ -359,4 +372,26 @@ async function GameProfiles(data) {
}
`
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)
+ }
}
\ No newline at end of file
diff --git a/js/store/item-view.js b/js/store/item-view.js
index 2fd3e23..caf9577 100755
--- a/js/store/item-view.js
+++ b/js/store/item-view.js
@@ -1,4 +1,5 @@
const ItemID = window.location.pathname.split('/')[2]
+const ItemType = document.querySelector('.col-12 .badge').innerHTML
var Utilities;
@@ -9,7 +10,7 @@ var WishlistBtn;
var ItemOwned;
(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 = Utilities.default
@@ -17,9 +18,12 @@ var ItemOwned;
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
Settings = result.PolyPlus_Settings || {}
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)
- if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
+ if (Settings.IRLPriceWithCurrencyOn === true) { IRLPrice() }
if (Settings.ItemWishlistOn === true) {
HandleItemWishlist()
diff --git a/js/store/store.js b/js/store/store.js
index 933226f..24e7a54 100755
--- a/js/store/store.js
+++ b/js/store/store.js
@@ -19,9 +19,16 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
});
function Update() {
- console.log('update')
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});
async function LoadIRLPrices(element) {
- console.log('LOAD IRL PRICES!!!')
if (element.tagName != "DIV") {return}
if (element.querySelector('small.text-primary')) {return}
const Parent = element.getElementsByTagName('small')[1]
if (Parent.innerText === "") { return }
- let Span = document.createElement('span')
+ const Span = document.createElement('span')
Span.classList = 'text-muted polyplus-price-tag'
Span.style.fontSize = '0.7rem'
const Price = Parent.innerText