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)
|
||||
|
||||
/*
|
||||
let Currencies;
|
||||
|
||||
LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){
|
||||
Currencies = JSON.parse(text)
|
||||
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 DIV = document.createElement('div')
|
||||
|
|
@ -21,6 +29,7 @@ DIV.innerHTML = `
|
|||
<option value="AUD">Australian Dollar (AUD)</option>
|
||||
<option value="TRY">Turkish Lira (TRY)</option>
|
||||
</select>
|
||||
<!--
|
||||
<select id="polyplus-brickconverter-package" class="form-select bg-dark">
|
||||
<option value="0" selected>$0.99 USD</option>
|
||||
<option value="1">$4.99 USD</option>
|
||||
|
|
@ -29,6 +38,7 @@ DIV.innerHTML = `
|
|||
<option value="4">c</option>
|
||||
<option value="5">d</option>
|
||||
</select>
|
||||
-->
|
||||
`
|
||||
Nav.appendChild(document.createElement('hr'))
|
||||
Nav.appendChild(DIV)
|
||||
|
|
@ -39,9 +49,9 @@ let Type = document.getElementById('polyplus-brickconverter-type')
|
|||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||
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()
|
||||
});
|
||||
|
||||
|
|
@ -49,48 +59,18 @@ Type.addEventListener('change', function(){
|
|||
Update()
|
||||
});
|
||||
|
||||
/*
|
||||
Package.addEventListener('change', function(){
|
||||
Update()
|
||||
});
|
||||
*/
|
||||
|
||||
function Update(){
|
||||
let DISPLAY = Type.options[Type.selectedIndex].value
|
||||
let IRL = (parseInt(Input.value.replace(/,/g, '')) * Currencies.Data[Package.selectedIndex][DISPLAY]).toFixed(2)
|
||||
/*
|
||||
var IRL;
|
||||
var 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
|
||||
async function Update(){
|
||||
//let DISPLAY = Type.options[Type.selectedIndex].value
|
||||
//let IRL = (parseInt(Input.value.replace(/,/g, '')) * Currencies.Data[Package.selectedIndex][DISPLAY]).toFixed(2)
|
||||
const Result = await Utilities.CalculateIRL(Input.value, Type.selectedIndex)
|
||||
console.log(Input.value, Type.options[Type.selectedIndex].value, Result)
|
||||
Output.value = "$" + Result.bricks + " " + Result.display
|
||||
}
|
||||
|
||||
function LoadFile(path, callback) {
|
||||
|
|
|
|||
409
js/everywhere.js
409
js/everywhere.js
|
|
@ -1,258 +1,179 @@
|
|||
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;
|
||||
|
||||
chrome.storage.sync.get(["PolyPlus_Settings"], function(result) {
|
||||
// Merge settings and expected settings to make sure all keys exist
|
||||
let RawSettings = result.PolyPlus_Settings
|
||||
Settings = MergeObjects(RawSettings || ExpectedSettings, ExpectedSettings);
|
||||
//chrome.storage.sync.set({ 'PolyPlus_Settings': Settings, arrayOrder: true }, function() {});
|
||||
(async () => {
|
||||
let Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||
Utilities = Utilities.default
|
||||
|
||||
// If theme exists, create a style element to represent it
|
||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||
Theme = document.createElement('style')
|
||||
switch (Settings.ThemeCreator.BGImageSize) {
|
||||
case 0:
|
||||
Settings.ThemeCreator.BGImageSize = 'fit'
|
||||
break
|
||||
case 1:
|
||||
Settings.ThemeCreator.BGImageSize = 'cover'
|
||||
break
|
||||
case 2:
|
||||
Settings.ThemeCreator.BGImageSize = 'contain'
|
||||
break
|
||||
chrome.storage.sync.get(["PolyPlus_Settings"], function(result) {
|
||||
// Merge settings and expected settings to make sure all keys exist
|
||||
const RawSettings = result.PolyPlus_Settings
|
||||
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
||||
|
||||
// If theme exists, create a style element to represent it
|
||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||
Theme = document.createElement('style')
|
||||
switch (Settings.ThemeCreator.BGImageSize) {
|
||||
case 0:
|
||||
Settings.ThemeCreator.BGImageSize = 'fit'
|
||||
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};
|
||||
--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};
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
if (document.getElementsByClassName('card-header')[0] && document.getElementsByClassName('card-header')[0].innerText === ' Page not found') {
|
||||
return
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
`
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
// 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.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
|
||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) {
|
||||
document.body.prepend(Theme)
|
||||
}
|
||||
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) {
|
||||
document.querySelectorAll('.notif-nav.notif-sidebar').forEach(element => {element.remove();});
|
||||
}
|
||||
});
|
||||
// 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('.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) {
|
||||
var mergedObj = {};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
const InExtensionSettings = (window.location.pathname.split('/')[3] === "polyplus")
|
||||
if (InExtensionSettings === true) {
|
||||
window.location.href = chrome.runtime.getURL('settings.html')
|
||||
}
|
||||
if (InExtensionSettings === true) { window.location.href = chrome.runtime.getURL('settings.html') }
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
const Nav = document.getElementsByClassName('nav nav-pills')[0]
|
||||
|
|
|
|||
|
|
@ -1,95 +1,105 @@
|
|||
export default {
|
||||
DefaultSettings: {
|
||||
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()
|
||||
/*
|
||||
HOW TO USE IN CONTENT SCRIPTS:
|
||||
|
||||
let IRL;
|
||||
let DISPLAY;
|
||||
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}
|
||||
(async () => {
|
||||
let Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||
Utilities = Utilities.default
|
||||
})();
|
||||
*/
|
||||
|
||||
export default {
|
||||
DefaultSettings: {
|
||||
PinnedGamesOn: true,
|
||||
ForumMentsOn: true,
|
||||
BestFriendsOn: false,
|
||||
ImprovedFrListsOn: false,
|
||||
IRLPriceWithCurrencyOn: true,
|
||||
IRLPriceWithCurrencyCurrency: 0,
|
||||
IRLPriceWithCurrencyPackage: 0,
|
||||
HideNotifBadgesOn: false,
|
||||
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,
|
||||
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]
|
||||
|
||||
var Utilities;
|
||||
|
||||
var Settings;
|
||||
var ItemWishlist;
|
||||
var PurchaseBtn;
|
||||
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}
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||
var Settings = result.PolyPlus_Settings || {
|
||||
IRLPriceWithCurrencyOn: false,
|
||||
IRLPriceWithCurrencyCurrency: 0,
|
||||
ItemWishlistOn: true
|
||||
}
|
||||
Settings = result.PolyPlus_Settings || {}
|
||||
PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0]
|
||||
console.log(PurchaseBtn)
|
||||
|
||||
if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
|
||||
|
||||
if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) {
|
||||
console.log('AAAA')
|
||||
HandleItemWishlist()
|
||||
}
|
||||
})
|
||||
}, 100)
|
||||
})();
|
||||
|
||||
chrome.storage.onChanged.addListener(function(changes, namespace) {
|
||||
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'))) {
|
||||
let Price = PurchaseBtn.getAttribute('data-price').replace(/,/g, '')
|
||||
let Span = document.createElement('span')
|
||||
const Price = PurchaseBtn.getAttribute('data-price')
|
||||
const Span = document.createElement('span')
|
||||
Span.classList = 'text-muted polyplus-own-tag'
|
||||
Span.style.fontSize = '0.7rem'
|
||||
Span.style.fontWeight = 'normal'
|
||||
let IRL;
|
||||
let 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 + ")"
|
||||
const Result = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrencyCurrency)
|
||||
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||
PurchaseBtn.appendChild(Span)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,25 @@
|
|||
setTimeout(function () {}, 100)
|
||||
var Settings = {IRLPriceWithCurrencyOn: true, IRLPriceWithCurrencyCurrency: 0, StoreOwnTagOn: true};
|
||||
var UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
|
||||
var ItemGrid = document.getElementById('assets')
|
||||
const UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
|
||||
|
||||
var Settings;
|
||||
|
||||
var Utilities;
|
||||
(async () => {
|
||||
Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js'));
|
||||
Utilities = Utilities.default
|
||||
|
||||
Update()
|
||||
})();
|
||||
|
||||
const ItemGrid = document.getElementById('assets')
|
||||
var Inventory = [];
|
||||
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||
Settings = result.PolyPlus_Settings;
|
||||
Settings = result.PolyPlus_Settings || Utilities.DefaultSettings;
|
||||
console.log(Settings)
|
||||
});
|
||||
|
||||
function Update() {
|
||||
console.log('update')
|
||||
if (Settings.IRLPriceWithCurrencyOn === true) {
|
||||
Array.from(ItemGrid.children).forEach(element => {LoadIRLPrices(element)});
|
||||
}
|
||||
|
|
@ -15,9 +27,7 @@ function Update() {
|
|||
|
||||
const observer = new MutationObserver(async function (list){
|
||||
for (const record of list) {
|
||||
console.log('record')
|
||||
for (const element of record.addedNodes) {
|
||||
console.log('element', element.tagName, element.classList)
|
||||
if (element.tagName === "DIV" && element.classList.value === 'mb-3 itemCardCont') {
|
||||
if (Settings.IRLPriceWithCurrencyOn === true) {LoadIRLPrices(element)}
|
||||
if (Settings.StoreOwnTagOn === true) {
|
||||
|
|
@ -49,56 +59,23 @@ const observer = new MutationObserver(async function (list){
|
|||
|
||||
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.querySelector('small.text-primary')) {return}
|
||||
let Parent = element.getElementsByTagName('small')[1]
|
||||
if (Parent.innerText === "") {
|
||||
return
|
||||
}
|
||||
const Parent = element.getElementsByTagName('small')[1]
|
||||
if (Parent.innerText === "") { return }
|
||||
let Span = document.createElement('span')
|
||||
Span.classList = 'text-muted polyplus-price-tag'
|
||||
Span.style.fontSize = '0.7rem'
|
||||
let Price = parseInt(Parent.innerText.replace(/,/g, ''))
|
||||
var IRL;
|
||||
var 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 + ")"
|
||||
const Price = Parent.innerText
|
||||
const Result = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrencyCurrency)
|
||||
Span.innerText = "($" + Result.bricks + " " + Result.display + ")"
|
||||
Parent.appendChild(Span)
|
||||
}
|
||||
|
||||
function LoadOwnedTags(element) {
|
||||
let Item = CheckInventory(parseInt(element.querySelector('[href^="/store/"]').getAttribute('href').split('/')[2]))
|
||||
console.log(Item, Item.id)
|
||||
if (Item.id) {
|
||||
var Tag = document.createElement('span')
|
||||
Tag.classList = 'badge bg-primary polyplus-own-tag'
|
||||
|
|
@ -108,7 +85,7 @@ function LoadOwnedTags(element) {
|
|||
} else {
|
||||
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/*"],
|
||||
"matches": ["https://polytoria.com/*"]
|
||||
},
|
||||
|
||||
{
|
||||
"resources": ["settings.html", "settings.js"],
|
||||
"matches": ["https://polytoria.com/*"]
|
||||
}
|
||||
],
|
||||
"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>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
|
|
|||
23
settings.js
23
settings.js
|
|
@ -2,6 +2,7 @@ const SaveBtn = document.getElementById('Save')
|
|||
const Elements = Array.from(document.getElementsByClassName('setting-container'))
|
||||
|
||||
var Settings;
|
||||
/*
|
||||
var ExpectedSettings = {
|
||||
PinnedGamesOn: true,
|
||||
ForumMentsOn: false,
|
||||
|
|
@ -52,6 +53,15 @@ var ExpectedSettings = {
|
|||
ItemWishlistOn: true,
|
||||
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')
|
||||
var ThemeCreatorModal = {
|
||||
|
|
@ -280,6 +290,12 @@ document.getElementById('ThemeCreator').getElementsByTagName('button')[1].addEve
|
|||
CopyThemeJSONBtn.addEventListener('click', function(){
|
||||
if (SaveThemeToJSONInput.value.length > 0) {
|
||||
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) {
|
||||
alert('This feature has been disabled for now.')
|
||||
return
|
||||
try {
|
||||
let JSONTable = JSON.parse(string)
|
||||
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) {
|
||||
LoadThemeFromJSONBtn.previousElementSibling.value = ''
|
||||
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)
|
||||
Save();
|
||||
console.log(JSONTable.length, JSONTable, 'applied')
|
||||
|
|
|
|||
Reference in a new issue