Importing Utility Module!!!!!!!!!
- Repetitive code is now way easier to edit as it is now stored in the utility module rather than the same code in several different files - Changed "Theme Creator" Copy JSON button to have the text "Copy" rather than rely on an icon due to me forgetting to import fontawesome - Hopefully fixed the store page randomly not working by not showing IRL prices or not showing the owned tags (may rewrite the entire code for that file since it is pretty old like Early Summer 2023) - Fixed clicking on "Poly+" in the sidebar on the settings page sending you to an invalid page (due to browser security stuff) which wasn't happening to me before public beta - Disabled importing theme data JSON for now to ensure security
This commit is contained in:
parent
d4cc322040
commit
3d6b265de0
9 changed files with 360 additions and 475 deletions
|
|
@ -1,11 +1,19 @@
|
||||||
setTimeout(function () {}, 100)
|
setTimeout(function () {}, 100)
|
||||||
|
|
||||||
|
/*
|
||||||
let Currencies;
|
let Currencies;
|
||||||
|
|
||||||
LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){
|
LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){
|
||||||
Currencies = JSON.parse(text)
|
Currencies = JSON.parse(text)
|
||||||
console.log(new Date(Currencies.Date).toLocaleDateString("en-US", {day:"numeric",month:"long",year:"numeric"}), Currencies)
|
console.log(new Date(Currencies.Date).toLocaleDateString("en-US", {day:"numeric",month:"long",year:"numeric"}), Currencies)
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
let Utilities;
|
||||||
|
(async () => {
|
||||||
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
})();
|
||||||
|
|
||||||
let Nav = document.querySelector('.nav-pills')
|
let Nav = document.querySelector('.nav-pills')
|
||||||
let DIV = document.createElement('div')
|
let DIV = document.createElement('div')
|
||||||
|
|
@ -21,6 +29,7 @@ DIV.innerHTML = `
|
||||||
<option value="AUD">Australian Dollar (AUD)</option>
|
<option value="AUD">Australian Dollar (AUD)</option>
|
||||||
<option value="TRY">Turkish Lira (TRY)</option>
|
<option value="TRY">Turkish Lira (TRY)</option>
|
||||||
</select>
|
</select>
|
||||||
|
<!--
|
||||||
<select id="polyplus-brickconverter-package" class="form-select bg-dark">
|
<select id="polyplus-brickconverter-package" class="form-select bg-dark">
|
||||||
<option value="0" selected>$0.99 USD</option>
|
<option value="0" selected>$0.99 USD</option>
|
||||||
<option value="1">$4.99 USD</option>
|
<option value="1">$4.99 USD</option>
|
||||||
|
|
@ -29,6 +38,7 @@ DIV.innerHTML = `
|
||||||
<option value="4">c</option>
|
<option value="4">c</option>
|
||||||
<option value="5">d</option>
|
<option value="5">d</option>
|
||||||
</select>
|
</select>
|
||||||
|
-->
|
||||||
`
|
`
|
||||||
Nav.appendChild(document.createElement('hr'))
|
Nav.appendChild(document.createElement('hr'))
|
||||||
Nav.appendChild(DIV)
|
Nav.appendChild(DIV)
|
||||||
|
|
@ -39,9 +49,9 @@ let Type = document.getElementById('polyplus-brickconverter-type')
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||||
Type.selectedIndex = result.PolyPlus_Settings.IRLPriceWithCurrencyCurrency || 0
|
Type.selectedIndex = result.PolyPlus_Settings.IRLPriceWithCurrencyCurrency || 0
|
||||||
});
|
});
|
||||||
let Package = document.getElementById('polyplus-brickconverter-package')
|
//let Package = document.getElementById('polyplus-brickconverter-package')
|
||||||
|
|
||||||
Input.addEventListener('change', function(){
|
Input.addEventListener('input', function(){
|
||||||
Update()
|
Update()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -49,48 +59,18 @@ Type.addEventListener('change', function(){
|
||||||
Update()
|
Update()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
Package.addEventListener('change', function(){
|
Package.addEventListener('change', function(){
|
||||||
Update()
|
Update()
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
function Update(){
|
async function Update(){
|
||||||
let DISPLAY = Type.options[Type.selectedIndex].value
|
//let DISPLAY = Type.options[Type.selectedIndex].value
|
||||||
let IRL = (parseInt(Input.value.replace(/,/g, '')) * Currencies.Data[Package.selectedIndex][DISPLAY]).toFixed(2)
|
//let IRL = (parseInt(Input.value.replace(/,/g, '')) * Currencies.Data[Package.selectedIndex][DISPLAY]).toFixed(2)
|
||||||
/*
|
const Result = await Utilities.CalculateIRL(Input.value, Type.selectedIndex)
|
||||||
var IRL;
|
console.log(Input.value, Type.options[Type.selectedIndex].value, Result)
|
||||||
var DISPLAY;
|
Output.value = "$" + Result.bricks + " " + Result.display
|
||||||
switch (Type.selectedIndex) {
|
|
||||||
case 0:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.0099).toFixed(2)
|
|
||||||
DISPLAY = 'USD'
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.009).toFixed(2)
|
|
||||||
DISPLAY = 'EUR'
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.0131).toFixed(2)
|
|
||||||
DISPLAY = 'CAD'
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.0077).toFixed(2)
|
|
||||||
DISPLAY = 'GBP'
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.1691).toFixed(2)
|
|
||||||
DISPLAY = 'MXN'
|
|
||||||
break
|
|
||||||
case 5:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.0144).toFixed(2)
|
|
||||||
DISPLAY = 'AUD'
|
|
||||||
break
|
|
||||||
case 6:
|
|
||||||
IRL = (parseInt(Input.value.replace(/,/g, '')) * 0.2338).toFixed(2)
|
|
||||||
DISPLAY = 'TRY'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Output.value = "$" + IRL + " " + DISPLAY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadFile(path, callback) {
|
function LoadFile(path, callback) {
|
||||||
|
|
|
||||||
409
js/everywhere.js
409
js/everywhere.js
|
|
@ -1,258 +1,179 @@
|
||||||
var Settings;
|
var Settings;
|
||||||
const ExpectedSettings = {
|
|
||||||
PinnedGamesOn: false,
|
|
||||||
ForumMentsOn: false,
|
|
||||||
BestFriendsOn: false,
|
|
||||||
ImprovedFrListsOn: false,
|
|
||||||
IRLPriceWithCurrencyOn: true,
|
|
||||||
IRLPriceWithCurrencyCurrency: 0,
|
|
||||||
IRLPriceWithCurrencyPackage: 0,
|
|
||||||
HideNotifBadgesOn: true,
|
|
||||||
StoreOwnTagOn: true,
|
|
||||||
ThemeCreatorOn: false,
|
|
||||||
ThemeCreator: {
|
|
||||||
BGColor: null,
|
|
||||||
BGImage: null,
|
|
||||||
BGImageSize: 'fit',
|
|
||||||
PrimaryTextColor: null,
|
|
||||||
SecondaryTextColor: null,
|
|
||||||
LinkTextColor: null,
|
|
||||||
WebsiteLogo: null
|
|
||||||
},
|
|
||||||
ModifyNavOn: false,
|
|
||||||
ModifyNav: [
|
|
||||||
{
|
|
||||||
Label: "Play",
|
|
||||||
Link: "https://polytoria.com/places"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Store",
|
|
||||||
Link: "https://polytoria.com/store"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Guilds",
|
|
||||||
Link: "https://polytoria.com/guilds"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "People",
|
|
||||||
Link: "https://polytoria.com/users"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Forum",
|
|
||||||
Link: "https://polytoria.com/forum"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
MoreSearchFiltersOn: true,
|
|
||||||
ApplyMembershipThemeOn: false,
|
|
||||||
ApplyMembershipThemeTheme: 0,
|
|
||||||
ForumMarkOn: true,
|
|
||||||
MultiCancelOutTradesOn: true,
|
|
||||||
ItemWishlistOn: true,
|
|
||||||
HideUpgradeBtnOn: false
|
|
||||||
}
|
|
||||||
let Theme = null;
|
let Theme = null;
|
||||||
|
|
||||||
chrome.storage.sync.get(["PolyPlus_Settings"], function(result) {
|
(async () => {
|
||||||
// Merge settings and expected settings to make sure all keys exist
|
let Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
let RawSettings = result.PolyPlus_Settings
|
Utilities = Utilities.default
|
||||||
Settings = MergeObjects(RawSettings || ExpectedSettings, ExpectedSettings);
|
|
||||||
//chrome.storage.sync.set({ 'PolyPlus_Settings': Settings, arrayOrder: true }, function() {});
|
|
||||||
|
|
||||||
// If theme exists, create a style element to represent it
|
chrome.storage.sync.get(["PolyPlus_Settings"], function(result) {
|
||||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
// Merge settings and expected settings to make sure all keys exist
|
||||||
Theme = document.createElement('style')
|
const RawSettings = result.PolyPlus_Settings
|
||||||
switch (Settings.ThemeCreator.BGImageSize) {
|
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
||||||
case 0:
|
|
||||||
Settings.ThemeCreator.BGImageSize = 'fit'
|
// If theme exists, create a style element to represent it
|
||||||
break
|
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||||
case 1:
|
Theme = document.createElement('style')
|
||||||
Settings.ThemeCreator.BGImageSize = 'cover'
|
switch (Settings.ThemeCreator.BGImageSize) {
|
||||||
break
|
case 0:
|
||||||
case 2:
|
Settings.ThemeCreator.BGImageSize = 'fit'
|
||||||
Settings.ThemeCreator.BGImageSize = 'contain'
|
break
|
||||||
break
|
case 1:
|
||||||
|
Settings.ThemeCreator.BGImageSize = 'cover'
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
Settings.ThemeCreator.BGImageSize = 'contain'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Theme.innerHTML = `
|
||||||
|
:root {
|
||||||
|
--polyplus-navbgcolor: ${Settings.ThemeCreator.NavBGColor};
|
||||||
|
--polyplus-navbordercolor: ${Settings.ThemeCreator.NavBorderColor};
|
||||||
|
--polyplus-navitemcolor: ${Settings.ThemeCreator.NavItemColor};
|
||||||
|
--polyplus-sidebarbgcolor: ${Settings.ThemeCreator.SideBGColor};
|
||||||
|
--polyplus-sidebarbordercolor: ${Settings.ThemeCreator.SideBorderColor};
|
||||||
|
--polyplus-sidebaritembgcolor: ${Settings.ThemeCreator.SideItemBGColor};
|
||||||
|
--polyplus-sidebaritembordercolor: ${Settings.ThemeCreator.SideItemBorderColor};
|
||||||
|
--polyplus-sidebaritemcolor: ${Settings.ThemeCreator.SideItemColor};
|
||||||
|
--polyplus-sidebaritemlabelcolor: ${Settings.ThemeCreator.SideItemLabelColor};
|
||||||
|
--polyplus-bgcolor: ${Settings.ThemeCreator.BGColor};
|
||||||
|
--polyplus-bgimage: url(${Settings.ThemeCreator.BGImage});
|
||||||
|
--polyplus-bgimagesize: ${Settings.ThemeCreator.BGImageSize};
|
||||||
|
--polyplus-primarytextcolor: ${Settings.ThemeCreator.PrimaryTextColor};
|
||||||
|
--polyplus-secondarytextcolor: ${Settings.ThemeCreator.SecondaryTextColor};
|
||||||
|
--polyplus-linktextcolor: ${Settings.ThemeCreator.LinkTextColor};
|
||||||
|
--polyplus-linkhoveredtextcolor: ${Settings.ThemeCreator.LinkHoveredTextColor};
|
||||||
|
--polyplus-linkfocusedtextcolor: ${Settings.ThemeCreator.LinkFocusedTextColor};
|
||||||
|
--polyplus-linkvisitedtextcolor: ${Settings.ThemeCreator.LinkVisitedTextColor};
|
||||||
|
--polyplus-cardheadbgcolor: ${Settings.ThemeCreator.CardHeadBGColor};
|
||||||
|
--polyplus-cardbodybgcolor: ${Settings.ThemeCreator.CardBodyBGColor};
|
||||||
|
--polyplus-cardbordercolor: ${Settings.ThemeCreator.CardBorderColor};
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
background-color: var(--polyplus-navbgcolor) !important;
|
||||||
|
border-bottom: 1px solid var(--polyplus-navbordercolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-sidebar {
|
||||||
|
background-color: var(--polyplus-sidebarbgcolor) !important;
|
||||||
|
border-right: 1px solid var(--polyplus-sidebarbordercolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
background-color: var(--polyplus-bgcolor) !important;
|
||||||
|
background-image: var(--polyplus-bgimage) !important;
|
||||||
|
background-size var(--polyplus-bgimagesize)
|
||||||
|
color: var(--polyplus-primarytextcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: var(--polyplus-secondarytextcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--polyplus-linktextcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: var(--polyplus-linkhoveredtextcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:focus {
|
||||||
|
color: var(--polyplus-linkfocusedtextcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
a:visited {
|
||||||
|
color: var(--polyplus-linkvisitedtextcolor) !important;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
background-color: var(--polyplus-cardheadbgcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background-color: var(--polyplus-cardbodybgcolor) !important;
|
||||||
|
border-color: var(--polyplus-cardbordercolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a.nav-link {
|
||||||
|
color: var(--polyplus-navitemcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-sidebar .nav-sidebar-button {
|
||||||
|
background-color: var(--polyplus-sidebaritembgcolor) !important;
|
||||||
|
border-color: var(--polyplus-sidebaritembordercolor) !important;
|
||||||
|
color: var(--polyplus-sidebaritemcolor) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-sidebar-text {
|
||||||
|
color: var(--polyplus-sidebaritemlabelcolor) !important;
|
||||||
|
}
|
||||||
|
`
|
||||||
}
|
}
|
||||||
Theme.innerHTML = `
|
});
|
||||||
:root {
|
|
||||||
--polyplus-navbgcolor: ${Settings.ThemeCreator.NavBGColor};
|
document.addEventListener('DOMContentLoaded', async function() {
|
||||||
--polyplus-navbordercolor: ${Settings.ThemeCreator.NavBorderColor};
|
if (document.getElementsByClassName('card-header')[0] && document.getElementsByClassName('card-header')[0].innerText === ' Page not found') {
|
||||||
--polyplus-navitemcolor: ${Settings.ThemeCreator.NavItemColor};
|
return
|
||||||
--polyplus-sidebarbgcolor: ${Settings.ThemeCreator.SideBGColor};
|
|
||||||
--polyplus-sidebarbordercolor: ${Settings.ThemeCreator.SideBorderColor};
|
|
||||||
--polyplus-sidebaritembgcolor: ${Settings.ThemeCreator.SideItemBGColor};
|
|
||||||
--polyplus-sidebaritembordercolor: ${Settings.ThemeCreator.SideItemBorderColor};
|
|
||||||
--polyplus-sidebaritemcolor: ${Settings.ThemeCreator.SideItemColor};
|
|
||||||
--polyplus-sidebaritemlabelcolor: ${Settings.ThemeCreator.SideItemLabelColor};
|
|
||||||
--polyplus-bgcolor: ${Settings.ThemeCreator.BGColor};
|
|
||||||
--polyplus-bgimage: url(${Settings.ThemeCreator.BGImage});
|
|
||||||
--polyplus-bgimagesize: ${Settings.ThemeCreator.BGImageSize};
|
|
||||||
--polyplus-primarytextcolor: ${Settings.ThemeCreator.PrimaryTextColor};
|
|
||||||
--polyplus-secondarytextcolor: ${Settings.ThemeCreator.SecondaryTextColor};
|
|
||||||
--polyplus-linktextcolor: ${Settings.ThemeCreator.LinkTextColor};
|
|
||||||
--polyplus-linkhoveredtextcolor: ${Settings.ThemeCreator.LinkHoveredTextColor};
|
|
||||||
--polyplus-linkfocusedtextcolor: ${Settings.ThemeCreator.LinkFocusedTextColor};
|
|
||||||
--polyplus-linkvisitedtextcolor: ${Settings.ThemeCreator.LinkVisitedTextColor};
|
|
||||||
--polyplus-cardheadbgcolor: ${Settings.ThemeCreator.CardHeadBGColor};
|
|
||||||
--polyplus-cardbodybgcolor: ${Settings.ThemeCreator.CardBodyBGColor};
|
|
||||||
--polyplus-cardbordercolor: ${Settings.ThemeCreator.CardBorderColor};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nav {
|
// Check if Theme Exists, if so Load It
|
||||||
background-color: var(--polyplus-navbgcolor) !important;
|
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||||
border-bottom: 1px solid var(--polyplus-navbordercolor) !important;
|
if (!(Settings.ThemeCreator.WebsiteLogo === null)) {
|
||||||
}
|
document.querySelector('.nav-sidebar img').setAttribute('src', Settings.ThemeCreator.WebsiteLogo)
|
||||||
|
|
||||||
.nav-sidebar {
|
|
||||||
background-color: var(--polyplus-sidebarbgcolor) !important;
|
|
||||||
border-right: 1px solid var(--polyplus-sidebarbordercolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#app {
|
|
||||||
background-color: var(--polyplus-bgcolor) !important;
|
|
||||||
background-image: var(--polyplus-bgimage) !important;
|
|
||||||
background-size var(--polyplus-bgimagesize)
|
|
||||||
color: var(--polyplus-primarytextcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-muted {
|
|
||||||
color: var(--polyplus-secondarytextcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: var(--polyplus-linktextcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: var(--polyplus-linkhoveredtextcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:focus {
|
|
||||||
color: var(--polyplus-linkfocusedtextcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
a:visited {
|
|
||||||
color: var(--polyplus-linkvisitedtextcolor) !important;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
background-color: var(--polyplus-cardheadbgcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background-color: var(--polyplus-cardbodybgcolor) !important;
|
|
||||||
border-color: var(--polyplus-cardbordercolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav a.nav-link {
|
|
||||||
color: var(--polyplus-navitemcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-sidebar .nav-sidebar-button {
|
|
||||||
background-color: var(--polyplus-sidebaritembgcolor) !important;
|
|
||||||
border-color: var(--polyplus-sidebaritembordercolor) !important;
|
|
||||||
color: var(--polyplus-sidebaritemcolor) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-sidebar-text {
|
|
||||||
color: var(--polyplus-sidebaritemlabelcolor) !important;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
if (document.getElementsByClassName('card-header')[0] && document.getElementsByClassName('card-header')[0].innerText === ' Page not found') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if Theme Exists, if so Load It
|
|
||||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
|
||||||
if (!(Settings.ThemeCreator.WebsiteLogo === null)) {
|
|
||||||
document.querySelector('.nav-sidebar img').setAttribute('src', Settings.ThemeCreator.WebsiteLogo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) {
|
|
||||||
document.body.prepend(Theme)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define Data
|
|
||||||
const UserData = {
|
|
||||||
Username: document.querySelector('a.text-reset.text-decoration-none[href^="/users"]').innerText.replace(/\s+/g,''),
|
|
||||||
ID: document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2],
|
|
||||||
Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'')
|
|
||||||
}
|
|
||||||
|
|
||||||
window.localStorage.setItem('account_info', JSON.stringify(UserData))
|
|
||||||
document.body.setAttribute('data-URL', window.location.href)
|
|
||||||
|
|
||||||
// Add PolyPlus Settings link to Sidebar
|
|
||||||
const Parent = document.querySelector('ul.nav.nav-flush')
|
|
||||||
const Clone = Parent.querySelectorAll('li.nav-item')[0].cloneNode(true)
|
|
||||||
Clone.getElementsByTagName('a')[0].href = '/my/settings/polyplus'
|
|
||||||
Clone.getElementsByTagName('span')[0].innerText = "Poly+"
|
|
||||||
const Icon = Clone.querySelector('i')
|
|
||||||
Icon.classList = 'fa-regular fa-sparkles'
|
|
||||||
|
|
||||||
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
|
|
||||||
let NavbarItems = document.querySelectorAll('#main-content nav.navbar .nav-link')
|
|
||||||
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) {
|
|
||||||
Needed[i].children[1].innerText = Settings.ModifyNav[i].Label
|
|
||||||
Needed[i].href = Settings.ModifyNav[i].Link
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) {
|
||||||
|
document.body.prepend(Theme)
|
||||||
if (Settings.HideUpgradeBtnOn && Settings.HideUpgradeBtnOn === true) {
|
|
||||||
document.querySelector('.nav-sidebar a[href="/upgrade"].nav-link.py-1.nav-sidebar-link').remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.IRLPriceWithCurrencyOn && Settings.IRLPriceWithCurrencyOn === true) {
|
|
||||||
var IRL;
|
|
||||||
var DISPLAY;
|
|
||||||
switch (Settings.IRLPriceWithCurrencyCurrency) {
|
|
||||||
case 0:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.0099).toFixed(2)
|
|
||||||
DISPLAY = 'USD'
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.009).toFixed(2)
|
|
||||||
DISPLAY = 'EUR'
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.0131).toFixed(2)
|
|
||||||
DISPLAY = 'CAD'
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.0077).toFixed(2)
|
|
||||||
DISPLAY = 'GBP'
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.1691).toFixed(2)
|
|
||||||
DISPLAY = 'MXN'
|
|
||||||
break
|
|
||||||
case 5:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.0144).toFixed(2)
|
|
||||||
DISPLAY = 'AUD'
|
|
||||||
break
|
|
||||||
case 6:
|
|
||||||
IRL = (UserData.Bricks.replace(/,/g, '') * 0.2338).toFixed(2)
|
|
||||||
DISPLAY = 'TRY'
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
let BrickBalanceCount = [document.querySelector('.text-success .brickBalanceCount'), document.querySelector('.text-success .brickBalanceCont')]
|
|
||||||
BrickBalanceCount.forEach(element => {
|
|
||||||
element.innerText = element.innerText + ` ($${IRL} ${DISPLAY})`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.HideNotifBadgesOn && Settings.HideNotifBadgesOn === true) {
|
// Define Data
|
||||||
document.querySelectorAll('.notif-nav.notif-sidebar').forEach(element => {element.remove();});
|
const UserData = {
|
||||||
}
|
Username: document.querySelector('a.text-reset.text-decoration-none[href^="/users"]').innerText.replace(/\s+/g,''),
|
||||||
});
|
ID: document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2],
|
||||||
|
Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'')
|
||||||
|
}
|
||||||
|
|
||||||
|
window.localStorage.setItem('account_info', JSON.stringify(UserData))
|
||||||
|
document.body.setAttribute('data-URL', window.location.href)
|
||||||
|
|
||||||
|
// Add PolyPlus Settings link to Sidebar
|
||||||
|
const Parent = document.querySelector('ul.nav.nav-flush')
|
||||||
|
const Clone = Parent.querySelectorAll('li.nav-item')[0].cloneNode(true)
|
||||||
|
Clone.getElementsByTagName('a')[0].href = '/my/settings/polyplus'
|
||||||
|
Clone.getElementsByTagName('span')[0].innerText = "Poly+"
|
||||||
|
const Icon = Clone.querySelector('i')
|
||||||
|
Icon.classList = 'fa-regular fa-sparkles'
|
||||||
|
|
||||||
|
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]]
|
||||||
|
for (let i = 0; i < Settings.ModifyNav.length; i++) {
|
||||||
|
if (Settings.ModifyNav[i].Label != null) {
|
||||||
|
console.log(Needed[i], Needed[i].children[1])
|
||||||
|
Needed[i].children[1].innerText = Settings.ModifyNav[i].Label
|
||||||
|
Needed[i].href = Settings.ModifyNav[i].Link
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.HideUpgradeBtnOn && Settings.HideUpgradeBtnOn === true) {
|
||||||
|
document.querySelector('.nav-sidebar a[href="/upgrade"].nav-link.py-1.nav-sidebar-link').remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.IRLPriceWithCurrencyOn && Settings.IRLPriceWithCurrencyOn === true) {
|
||||||
|
const IRL = await Utilities.CalculateIRL(UserData.Bricks, Settings.IRLPriceWithCurrencyCurrency)
|
||||||
|
const BrickBalanceCount = [document.querySelector('.text-success .brickBalanceCount'), document.querySelector('.text-success .brickBalanceCont')]
|
||||||
|
BrickBalanceCount.forEach(element => {element.innerText = element.innerText + ` ($${IRL.bricks} ${IRL.display})`});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.HideNotifBadgesOn && Settings.HideNotifBadgesOn === true) {
|
||||||
|
document.querySelectorAll('.notif-nav.notif-sidebar').forEach(element => {element.remove();});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
function MergeObjects(obj1, obj2) {
|
function MergeObjects(obj1, obj2) {
|
||||||
var mergedObj = {};
|
var mergedObj = {};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
const InExtensionSettings = (window.location.pathname.split('/')[3] === "polyplus")
|
const InExtensionSettings = (window.location.pathname.split('/')[3] === "polyplus")
|
||||||
if (InExtensionSettings === true) {
|
if (InExtensionSettings === true) { window.location.href = chrome.runtime.getURL('settings.html') }
|
||||||
window.location.href = chrome.runtime.getURL('settings.html')
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function(){
|
document.addEventListener('DOMContentLoaded', function(){
|
||||||
const Nav = document.getElementsByClassName('nav nav-pills')[0]
|
const Nav = document.getElementsByClassName('nav nav-pills')[0]
|
||||||
|
|
|
||||||
|
|
@ -1,95 +1,105 @@
|
||||||
export default {
|
/*
|
||||||
DefaultSettings: {
|
HOW TO USE IN CONTENT SCRIPTS:
|
||||||
PinnedGamesOn: false,
|
|
||||||
ForumMentsOn: false,
|
|
||||||
BestFriendsOn: false,
|
|
||||||
ImprovedFrListsOn: false,
|
|
||||||
IRLPriceWithCurrencyOn: true,
|
|
||||||
IRLPriceWithCurrencyCurrency: 0,
|
|
||||||
IRLPriceWithCurrencyPackage: 0,
|
|
||||||
HideNotifBadgesOn: true,
|
|
||||||
SimplifiedProfileURLsOn: true,
|
|
||||||
StoreOwnTagOn: true,
|
|
||||||
ThemeCreatorOn: false,
|
|
||||||
ThemeCreator: {
|
|
||||||
BGColor: null,
|
|
||||||
BGImage: null,
|
|
||||||
BGImageSize: 'fit',
|
|
||||||
PrimaryTextColor: null,
|
|
||||||
SecondaryTextColor: null,
|
|
||||||
LinkTextColor: null,
|
|
||||||
WebsiteLogo: null
|
|
||||||
},
|
|
||||||
ModifyNavOn: false,
|
|
||||||
ModifyNav: [
|
|
||||||
{
|
|
||||||
Label: "Play",
|
|
||||||
Link: "https://polytoria.com/places"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Store",
|
|
||||||
Link: "https://polytoria.com/store"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Guilds",
|
|
||||||
Link: "https://polytoria.com/guilds"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "People",
|
|
||||||
Link: "https://polytoria.com/users"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Label: "Forum",
|
|
||||||
Link: "https://polytoria.com/forum"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
MoreSearchFiltersOn: true,
|
|
||||||
ApplyMembershipThemeOn: false,
|
|
||||||
ApplyMembershipThemeTheme: 0,
|
|
||||||
ForumMarkOn: true,
|
|
||||||
MultiCancelOutTradesOn: true,
|
|
||||||
ItemWishlistOn: true,
|
|
||||||
HideUpgradeBtnOn: false
|
|
||||||
},
|
|
||||||
CalculateIRL: async function(bricks, to) {
|
|
||||||
const response = await fetch(chrome.runtime.getURL('/js/resources/currencies.json'))
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Getting currency data failure')
|
|
||||||
}
|
|
||||||
const data = await response.json()
|
|
||||||
|
|
||||||
let IRL;
|
(async () => {
|
||||||
let DISPLAY;
|
let Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
switch (to) {
|
Utilities = Utilities.default
|
||||||
case 0:
|
})();
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.0099).toFixed(2)
|
*/
|
||||||
DISPLAY = 'USD'
|
|
||||||
break
|
export default {
|
||||||
case 1:
|
DefaultSettings: {
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.009).toFixed(2)
|
PinnedGamesOn: true,
|
||||||
DISPLAY = 'EUR'
|
ForumMentsOn: true,
|
||||||
break
|
BestFriendsOn: false,
|
||||||
case 2:
|
ImprovedFrListsOn: false,
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.0131).toFixed(2)
|
IRLPriceWithCurrencyOn: true,
|
||||||
DISPLAY = 'CAD'
|
IRLPriceWithCurrencyCurrency: 0,
|
||||||
break
|
IRLPriceWithCurrencyPackage: 0,
|
||||||
case 3:
|
HideNotifBadgesOn: false,
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.0077).toFixed(2)
|
StoreOwnTagOn: true,
|
||||||
DISPLAY = 'GBP'
|
ThemeCreatorOn: false,
|
||||||
break
|
ThemeCreator: {
|
||||||
case 4:
|
BGColor: null,
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.1691).toFixed(2)
|
BGImage: null,
|
||||||
DISPLAY = 'MXN'
|
BGImageSize: 'fit',
|
||||||
break
|
PrimaryTextColor: null,
|
||||||
case 5:
|
SecondaryTextColor: null,
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.0144).toFixed(2)
|
LinkTextColor: null,
|
||||||
DISPLAY = 'AUD'
|
WebsiteLogo: null
|
||||||
break
|
},
|
||||||
case 6:
|
ModifyNavOn: false,
|
||||||
IRL = (bricks.replace(/,/g, '') * 0.2338).toFixed(2)
|
ModifyNav: [
|
||||||
DISPLAY = 'TRY'
|
{
|
||||||
break
|
Label: "Play",
|
||||||
}
|
Link: "https://polytoria.com/places"
|
||||||
return {bricks: IRL, display: DISPLAY}
|
},
|
||||||
|
{
|
||||||
|
Label: "Store",
|
||||||
|
Link: "https://polytoria.com/store"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Label: "Guilds",
|
||||||
|
Link: "https://polytoria.com/guilds"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Label: "People",
|
||||||
|
Link: "https://polytoria.com/users"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Label: "Forum",
|
||||||
|
Link: "https://polytoria.com/forum"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
MoreSearchFiltersOn: true,
|
||||||
|
ApplyMembershipThemeOn: false,
|
||||||
|
ApplyMembershipThemeTheme: 0,
|
||||||
|
MultiCancelOutTradesOn: true,
|
||||||
|
ItemWishlistOn: true,
|
||||||
|
HideUpgradeBtnOn: false
|
||||||
|
},
|
||||||
|
CalculateIRL: async function(bricks, to, brickPackage) {
|
||||||
|
/*
|
||||||
|
const response = await fetch(chrome.runtime.getURL('/js/resources/currencies.json'))
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Getting currency data failure')
|
||||||
}
|
}
|
||||||
|
const data = await response.json()
|
||||||
|
*/
|
||||||
|
|
||||||
|
let IRL;
|
||||||
|
let DISPLAY;
|
||||||
|
//const UnitPrice = data.Data[brickPackage][to]
|
||||||
|
switch (to) {
|
||||||
|
case 0:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.0099).toFixed(2)
|
||||||
|
DISPLAY = 'USD'
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.009).toFixed(2)
|
||||||
|
DISPLAY = 'EUR'
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.0131).toFixed(2)
|
||||||
|
DISPLAY = 'CAD'
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.0077).toFixed(2)
|
||||||
|
DISPLAY = 'GBP'
|
||||||
|
break
|
||||||
|
case 4:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.1691).toFixed(2)
|
||||||
|
DISPLAY = 'MXN'
|
||||||
|
break
|
||||||
|
case 5:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.0144).toFixed(2)
|
||||||
|
DISPLAY = 'AUD'
|
||||||
|
break
|
||||||
|
case 6:
|
||||||
|
IRL = (bricks.replace(/,/g, '') * 0.2338).toFixed(2)
|
||||||
|
DISPLAY = 'TRY'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return {bricks: IRL, display: DISPLAY}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,28 +1,30 @@
|
||||||
const ItemID = window.location.pathname.split('/')[2]
|
const ItemID = window.location.pathname.split('/')[2]
|
||||||
|
|
||||||
|
var Utilities;
|
||||||
|
|
||||||
|
var Settings;
|
||||||
var ItemWishlist;
|
var ItemWishlist;
|
||||||
var PurchaseBtn;
|
var PurchaseBtn;
|
||||||
var WishlistBtn;
|
var WishlistBtn;
|
||||||
|
|
||||||
setTimeout(function () {
|
(async () => {
|
||||||
|
if (!(window.location.href.split('/')[4])) {return}
|
||||||
|
|
||||||
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
|
||||||
if (!(window.location.href.split('/')[4])) {return}
|
if (!(window.location.href.split('/')[4])) {return}
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||||
var Settings = result.PolyPlus_Settings || {
|
Settings = result.PolyPlus_Settings || {}
|
||||||
IRLPriceWithCurrencyOn: false,
|
|
||||||
IRLPriceWithCurrencyCurrency: 0,
|
|
||||||
ItemWishlistOn: true
|
|
||||||
}
|
|
||||||
PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0]
|
PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0]
|
||||||
console.log(PurchaseBtn)
|
|
||||||
|
|
||||||
if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
|
if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
|
||||||
|
|
||||||
if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) {
|
if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) {
|
||||||
console.log('AAAA')
|
|
||||||
HandleItemWishlist()
|
HandleItemWishlist()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 100)
|
})();
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(function(changes, namespace) {
|
chrome.storage.onChanged.addListener(function(changes, namespace) {
|
||||||
if ('PolyPlus_ItemWishlist' in changes) {
|
if ('PolyPlus_ItemWishlist' in changes) {
|
||||||
|
|
@ -53,46 +55,15 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function IRLPrice() {
|
async function IRLPrice() {
|
||||||
if (!(PurchaseBtn.getAttribute('disabled'))) {
|
if (!(PurchaseBtn.getAttribute('disabled'))) {
|
||||||
let Price = PurchaseBtn.getAttribute('data-price').replace(/,/g, '')
|
const Price = PurchaseBtn.getAttribute('data-price')
|
||||||
let Span = document.createElement('span')
|
const Span = document.createElement('span')
|
||||||
Span.classList = 'text-muted polyplus-own-tag'
|
Span.classList = 'text-muted polyplus-own-tag'
|
||||||
Span.style.fontSize = '0.7rem'
|
Span.style.fontSize = '0.7rem'
|
||||||
Span.style.fontWeight = 'normal'
|
Span.style.fontWeight = 'normal'
|
||||||
let IRL;
|
const Result = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrencyCurrency)
|
||||||
let DISPLAY;
|
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||||
switch (Settings.IRLPriceWithCurrencyCurrency) {
|
|
||||||
case 0:
|
|
||||||
IRL = (Price * 0.0099).toFixed(2)
|
|
||||||
DISPLAY = 'USD'
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
IRL = (Price * 0.009).toFixed(2)
|
|
||||||
DISPLAY = 'EUR'
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
IRL = (Price * 0.0131).toFixed(2)
|
|
||||||
DISPLAY = 'CAD'
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
IRL = (Price * 0.0077).toFixed(2)
|
|
||||||
DISPLAY = 'GBP'
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
IRL = (Price * 0.1691).toFixed(2)
|
|
||||||
DISPLAY = 'MXN'
|
|
||||||
break
|
|
||||||
case 5:
|
|
||||||
IRL = (Price * 0.0144).toFixed(2)
|
|
||||||
DISPLAY = 'AUD'
|
|
||||||
break
|
|
||||||
case 6:
|
|
||||||
IRL = (Price * 0.2338).toFixed(2)
|
|
||||||
DISPLAY = 'TRY'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
Span.innerText = "($" + IRL + " " + DISPLAY + ")"
|
|
||||||
PurchaseBtn.appendChild(Span)
|
PurchaseBtn.appendChild(Span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,25 @@
|
||||||
setTimeout(function () {}, 100)
|
const UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
|
||||||
var Settings = {IRLPriceWithCurrencyOn: true, IRLPriceWithCurrencyCurrency: 0, StoreOwnTagOn: true};
|
|
||||||
var UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
|
var Settings;
|
||||||
var ItemGrid = document.getElementById('assets')
|
|
||||||
|
var Utilities;
|
||||||
|
(async () => {
|
||||||
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
|
||||||
|
Update()
|
||||||
|
})();
|
||||||
|
|
||||||
|
const ItemGrid = document.getElementById('assets')
|
||||||
var Inventory = [];
|
var Inventory = [];
|
||||||
|
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||||
Settings = result.PolyPlus_Settings;
|
Settings = result.PolyPlus_Settings || Utilities.DefaultSettings;
|
||||||
|
console.log(Settings)
|
||||||
});
|
});
|
||||||
|
|
||||||
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)});
|
||||||
}
|
}
|
||||||
|
|
@ -15,9 +27,7 @@ function Update() {
|
||||||
|
|
||||||
const observer = new MutationObserver(async function (list){
|
const observer = new MutationObserver(async function (list){
|
||||||
for (const record of list) {
|
for (const record of list) {
|
||||||
console.log('record')
|
|
||||||
for (const element of record.addedNodes) {
|
for (const element of record.addedNodes) {
|
||||||
console.log('element', element.tagName, element.classList)
|
|
||||||
if (element.tagName === "DIV" && element.classList.value === 'mb-3 itemCardCont') {
|
if (element.tagName === "DIV" && element.classList.value === 'mb-3 itemCardCont') {
|
||||||
if (Settings.IRLPriceWithCurrencyOn === true) {LoadIRLPrices(element)}
|
if (Settings.IRLPriceWithCurrencyOn === true) {LoadIRLPrices(element)}
|
||||||
if (Settings.StoreOwnTagOn === true) {
|
if (Settings.StoreOwnTagOn === true) {
|
||||||
|
|
@ -49,56 +59,23 @@ 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});
|
||||||
|
|
||||||
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}
|
||||||
let Parent = element.getElementsByTagName('small')[1]
|
const Parent = element.getElementsByTagName('small')[1]
|
||||||
if (Parent.innerText === "") {
|
if (Parent.innerText === "") { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
let Span = document.createElement('span')
|
let 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'
|
||||||
let Price = parseInt(Parent.innerText.replace(/,/g, ''))
|
const Price = Parent.innerText
|
||||||
var IRL;
|
const Result = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrencyCurrency)
|
||||||
var DISPLAY;
|
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||||
switch (Settings.IRLPriceWithCurrencyCurrency) {
|
|
||||||
case 0:
|
|
||||||
IRL = (Price * 0.0099).toFixed(2)
|
|
||||||
DISPLAY = 'USD'
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
IRL = (Price * 0.009).toFixed(2)
|
|
||||||
DISPLAY = 'EUR'
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
IRL = (Price * 0.0131).toFixed(2)
|
|
||||||
DISPLAY = 'CAD'
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
IRL = (Price * 0.0077).toFixed(2)
|
|
||||||
DISPLAY = 'GBP'
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
IRL = (Price * 0.1691).toFixed(2)
|
|
||||||
DISPLAY = 'MXN'
|
|
||||||
break
|
|
||||||
case 5:
|
|
||||||
IRL = (Price * 0.0144).toFixed(2)
|
|
||||||
DISPLAY = 'AUD'
|
|
||||||
break
|
|
||||||
case 6:
|
|
||||||
IRL = (Price * 0.2338).toFixed(2)
|
|
||||||
DISPLAY = 'TRY'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
Span.innerText = "($" + IRL + " " + DISPLAY + ")"
|
|
||||||
Parent.appendChild(Span)
|
Parent.appendChild(Span)
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadOwnedTags(element) {
|
function LoadOwnedTags(element) {
|
||||||
let Item = CheckInventory(parseInt(element.querySelector('[href^="/store/"]').getAttribute('href').split('/')[2]))
|
let Item = CheckInventory(parseInt(element.querySelector('[href^="/store/"]').getAttribute('href').split('/')[2]))
|
||||||
console.log(Item, Item.id)
|
|
||||||
if (Item.id) {
|
if (Item.id) {
|
||||||
var Tag = document.createElement('span')
|
var Tag = document.createElement('span')
|
||||||
Tag.classList = 'badge bg-primary polyplus-own-tag'
|
Tag.classList = 'badge bg-primary polyplus-own-tag'
|
||||||
|
|
@ -108,7 +85,7 @@ function LoadOwnedTags(element) {
|
||||||
} else {
|
} else {
|
||||||
Tag.innerHTML = 'owned<br><span class="text-muted" style="font-size: 0.65rem;">#' + Item.serial
|
Tag.innerHTML = 'owned<br><span class="text-muted" style="font-size: 0.65rem;">#' + Item.serial
|
||||||
}
|
}
|
||||||
element.querySelector('img').parentElement.appendChild(Tag)
|
element.getElementsByTagName('img')[0].parentElement.appendChild(Tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,11 @@
|
||||||
{
|
{
|
||||||
"resources": ["js/resources/*"],
|
"resources": ["js/resources/*"],
|
||||||
"matches": ["https://polytoria.com/*"]
|
"matches": ["https://polytoria.com/*"]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"resources": ["settings.html", "settings.js"],
|
||||||
|
"matches": ["https://polytoria.com/*"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"short_name": "Poly+",
|
"short_name": "Poly+",
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
<input id="SaveThemeToJSONInput" type="text" class="form-control bg-dark mb-2" placeholder="JSON..." data-ignore="true" disabled>
|
<input id="SaveThemeToJSONInput" type="text" class="form-control bg-dark mb-2" placeholder="JSON..." data-ignore="true" disabled>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button id="CopyThemeJSONBtn" class="btn btn-warning"><i class="fa-duotone fa-clipboard"></i></button>
|
<button id="CopyThemeJSONBtn" class="btn btn-warning"><!--<i class="fa-duotone fa-clipboard"></i>--> Copy</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
23
settings.js
23
settings.js
|
|
@ -2,6 +2,7 @@ const SaveBtn = document.getElementById('Save')
|
||||||
const Elements = Array.from(document.getElementsByClassName('setting-container'))
|
const Elements = Array.from(document.getElementsByClassName('setting-container'))
|
||||||
|
|
||||||
var Settings;
|
var Settings;
|
||||||
|
/*
|
||||||
var ExpectedSettings = {
|
var ExpectedSettings = {
|
||||||
PinnedGamesOn: true,
|
PinnedGamesOn: true,
|
||||||
ForumMentsOn: false,
|
ForumMentsOn: false,
|
||||||
|
|
@ -52,6 +53,15 @@ var ExpectedSettings = {
|
||||||
ItemWishlistOn: true,
|
ItemWishlistOn: true,
|
||||||
HideUpgradeBtnOn: false
|
HideUpgradeBtnOn: false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
var ExpectedSettings;
|
||||||
|
var Utilities;
|
||||||
|
(async () => {
|
||||||
|
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||||
|
Utilities = Utilities.default
|
||||||
|
|
||||||
|
ExpectedSettings = Utilities.DefaultSettings
|
||||||
|
})();
|
||||||
|
|
||||||
const ResetDefaultsModal = document.getElementById('ResetDefaults-Modal')
|
const ResetDefaultsModal = document.getElementById('ResetDefaults-Modal')
|
||||||
var ThemeCreatorModal = {
|
var ThemeCreatorModal = {
|
||||||
|
|
@ -280,6 +290,12 @@ document.getElementById('ThemeCreator').getElementsByTagName('button')[1].addEve
|
||||||
CopyThemeJSONBtn.addEventListener('click', function(){
|
CopyThemeJSONBtn.addEventListener('click', function(){
|
||||||
if (SaveThemeToJSONInput.value.length > 0) {
|
if (SaveThemeToJSONInput.value.length > 0) {
|
||||||
navigator.clipboard.writeText(SaveThemeToJSONInput.value)
|
navigator.clipboard.writeText(SaveThemeToJSONInput.value)
|
||||||
|
.then(() => {
|
||||||
|
alert('Successfully copied theme data to clipboard!')
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
alert('Failure to copy theme data to clipboard.')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -291,12 +307,19 @@ LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){
|
||||||
})
|
})
|
||||||
|
|
||||||
function LoadThemeJSON(string) {
|
function LoadThemeJSON(string) {
|
||||||
|
alert('This feature has been disabled for now.')
|
||||||
|
return
|
||||||
try {
|
try {
|
||||||
let JSONTable = JSON.parse(string)
|
let JSONTable = JSON.parse(string)
|
||||||
if (JSONTable.length === ExpectedSettings.ThemeCreator.length) {
|
if (JSONTable.length === ExpectedSettings.ThemeCreator.length) {
|
||||||
if (confirm('Are you sure you\'d like to replace this theme with the theme specified in the JSON?') === true) {
|
if (confirm('Are you sure you\'d like to replace this theme with the theme specified in the JSON?') === true) {
|
||||||
LoadThemeFromJSONBtn.previousElementSibling.value = ''
|
LoadThemeFromJSONBtn.previousElementSibling.value = ''
|
||||||
document.getElementById('ThemeCreator-Modal').close()
|
document.getElementById('ThemeCreator-Modal').close()
|
||||||
|
/*
|
||||||
|
for (let i = 0; i < JSONTable.length; i++) {
|
||||||
|
JSONTable[i] = new Sanitzer(JSONTable[i])
|
||||||
|
}
|
||||||
|
*/
|
||||||
Settings.ThemeCreator = MergeObjects(JSONTable, ExpectedSettings.ThemeCreator)
|
Settings.ThemeCreator = MergeObjects(JSONTable, ExpectedSettings.ThemeCreator)
|
||||||
Save();
|
Save();
|
||||||
console.log(JSONTable.length, JSONTable, 'applied')
|
console.log(JSONTable.length, JSONTable, 'applied')
|
||||||
|
|
|
||||||
Reference in a new issue