bug fixes and fix fresh installs
This commit is contained in:
parent
beb002feb9
commit
4577213ee9
4 changed files with 204 additions and 9 deletions
107
js/background.js
107
js/background.js
|
|
@ -1,6 +1,94 @@
|
|||
const Manifest = chrome.runtime.getManifest();
|
||||
const SettingsURL = chrome.runtime.getURL('settings.html');
|
||||
|
||||
const DefaultSettings = {
|
||||
PinnedGamesOn: true,
|
||||
ForumMentsOn: true,
|
||||
BestFriendsOn: false,
|
||||
ImprovedFrListsOn: false,
|
||||
IRLPriceWithCurrency: {
|
||||
Enabled: true,
|
||||
Currency: 0,
|
||||
Package: 0
|
||||
},
|
||||
IRLPriceWithCurrencyOn: true,
|
||||
IRLPriceWithCurrencyCurrency: 0,
|
||||
IRLPriceWithCurrencyPackage: 0,
|
||||
HideNotifBadgesOn: false,
|
||||
StoreOwnTagOn: true,
|
||||
ThemeCreatorOn: false,
|
||||
ThemeCreator: {
|
||||
Enabled: false,
|
||||
BGColor: null,
|
||||
BGImage: null,
|
||||
BGImageSize: 'fit',
|
||||
PrimaryTextColor: null,
|
||||
SecondaryTextColor: null,
|
||||
LinkTextColor: null,
|
||||
WebsiteLogo: null
|
||||
},
|
||||
ModifyNavOn: false,
|
||||
ModifyNav: [
|
||||
{
|
||||
Label: 'Places',
|
||||
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,
|
||||
ApplyMembershipTheme: {
|
||||
Enabled: false,
|
||||
Theme: 0
|
||||
},
|
||||
ApplyMembershipThemeOn: false,
|
||||
ApplyMembershipThemeTheme: 0,
|
||||
MultiCancelOutTradesOn: true,
|
||||
ItemWishlistOn: true,
|
||||
HideUpgradeBtnOn: false,
|
||||
TryOnItemsOn: true,
|
||||
OutfitCostOn: true,
|
||||
ShowPlaceRevenueOn: true,
|
||||
ReplaceItemSalesOn: false,
|
||||
HoardersListOn: true,
|
||||
HoardersList: {
|
||||
Enabled: true,
|
||||
AvatarsEnabled: false,
|
||||
MinCopies: 2
|
||||
},
|
||||
LibraryDownloadsOn: true,
|
||||
EventItemsCatOn: true,
|
||||
HomeFriendCountOn: true,
|
||||
HideUserAds: {
|
||||
Enabled: false,
|
||||
Banners: true,
|
||||
Rectangles: true
|
||||
}
|
||||
}
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||
const MergedSettings = MergeObjects((result.PolyPlus_Settings || DefaultSettings), DefaultSettings)
|
||||
chrome.storage.sync.set({'PolyPlus_Settings': MergedSettings}, function(){
|
||||
console.log('Successfully merged settings')
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// WHEN CLICKING ON EXTENSION ICON OPEN THE SETTINGS PAGE
|
||||
chrome.action.onClicked.addListener((tab) => {
|
||||
chrome.tabs.create({active: true, url: SettingsURL});
|
||||
|
|
@ -189,3 +277,22 @@ function CopyAvatarHash(hash) {
|
|||
alert('Failure to copy avatar hash.');
|
||||
});
|
||||
}
|
||||
|
||||
// MergeObjects function was written by ChatGPT cause I was lazy and it was awhile ago
|
||||
function MergeObjects(obj1, obj2) {
|
||||
var mergedObj = {};
|
||||
|
||||
// Copy the values from obj1 to the mergedObj
|
||||
for (var key in obj1) {
|
||||
mergedObj[key] = obj1[key];
|
||||
}
|
||||
|
||||
// Merge the values from obj2 into the mergedObj, favoring obj2 for non-existing keys in obj1
|
||||
for (var key in obj2) {
|
||||
if (!obj1.hasOwnProperty(key)) {
|
||||
mergedObj[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
|
||||
return mergedObj;
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
Debug page for Development
|
||||
Accessable at /my/settings/polyplus#dev
|
||||
Developer & Debug Page
|
||||
Accessable at /my/settings/polyplus#dev and /my/settings/polyplus#debug
|
||||
*/
|
||||
|
||||
if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash === '#dev') {
|
||||
document.title = 'Poly+ Debug - Polytoria';
|
||||
const Version = chrome.runtime.getManifest().version;
|
||||
document.title = 'Poly+ Debug - Polytoria';
|
||||
const Version = chrome.runtime.getManifest().version;
|
||||
|
||||
if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash === '#dev') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelector('#main-content .container').innerHTML = `
|
||||
<style>
|
||||
|
|
@ -22,7 +22,7 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has
|
|||
}
|
||||
</style>
|
||||
<div class="text-center mb-3">
|
||||
<h1 class="text-center" style="font-size: 4.6rem;">Poly+ Debug</h1>
|
||||
<h1 class="text-center" style="font-size: 4.6rem;">Poly+ Developer</h1>
|
||||
<p class="w-75 d-block mx-auto">This page is used by developers for debugging most data related things. It is unrecommended you modify any data on this page, but if you ever want to go ahead.</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
@ -235,7 +235,95 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has
|
|||
});
|
||||
|
||||
chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_BestFriends', 'PolyPlus_ItemWishlist'], function (bytes) {
|
||||
console.log(bytes)
|
||||
document.getElementById('data-size').innerText = bytes.toLocaleString();
|
||||
});
|
||||
});
|
||||
}
|
||||
} else if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash === '#debug') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
chrome.storage.sync.get(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_BestFriends', 'PolyPlus_ItemWishlist'], function(result) {
|
||||
document.querySelector('#main-content .container').innerHTML = `
|
||||
<style>
|
||||
#main-content .container label {
|
||||
font-size: 0.8rem;
|
||||
color: darkgray;
|
||||
}
|
||||
|
||||
#main-content .container label + p {
|
||||
margin-bottom: 4px;
|
||||
font-size: 0.9rem;
|
||||
margin-top: -4px;
|
||||
}
|
||||
</style>
|
||||
<div class="text-center mb-3">
|
||||
<h1 class="text-center" style="font-size: 4.6rem;">Poly+ Debug</h1>
|
||||
<p class="w-75 d-block mx-auto">This page is used by developers for debugging most data related things. It is unrecommended you modify any data on this page, but if you ever want to go ahead.</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5" style="padding-left: 0px;">
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h2>Settings</h2>
|
||||
<div style="padding: 10px; background: #171717; font-family: monospace; color: orange; font-size: 0.8rem; border-radius: 10px; position: relative;">
|
||||
${JSON.stringify((result.PolyPlus_Settings || {}), null, 2)
|
||||
.replaceAll('\n','<br>')
|
||||
.replaceAll(' ', ' ')
|
||||
.replaceAll('\t', ' ')}
|
||||
<!--<button class="btn btn-warning btn-sm" style="position: absolute; top: 0; right: 0; margin: 10px;" onclick="navigator.clipboard.writeText('${JSON.stringify((result.PolyPlus_Settings || [])).replaceAll('"', "\'")}') .then(() => {alert('copied')}) .catch(() => {});">copy</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="text-muted mb-1">Version: v${Version}</p>
|
||||
<p class="text-muted mb-3">Data Size: <span id="data-size">Loading</span> byte(s)</p>
|
||||
<button class="btn btn-primary btn-sm w-100" id="check-for-updates">Check for Updates</button>
|
||||
<a href="https://github.com/IndexingGitHub/PolyPlus" class="btn btn-dark btn-sm w-100 mt-2" target="_blank">Open GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
Created by <a href="/u/Index" target="_blank">Index</a>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h3>Pinned Games (${(result.PolyPlus_PinnedGames || []).length})</h3>
|
||||
<div style="padding: 10px; background: #171717; font-family: monospace; color: orange; font-size: 0.8rem; border-radius: 10px; position: relative;">
|
||||
${JSON.stringify((result.PolyPlus_PinnedGames || []), null, 2)
|
||||
.replaceAll('\n','<br>')
|
||||
.replaceAll(' ', ' ')
|
||||
.replaceAll('\t', ' ')}
|
||||
<button class="btn btn-warning btn-sm" style="position: absolute; top: 0; right: 0; margin: 10px;" onclick="navigator.clipboard.writeText('${JSON.stringify((result.PolyPlus_PinnedGames || []))}') .then(() => {alert('copied')}) .catch(() => {});">copy</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h3>Best Friends (${(result.PolyPlus_BestFriends || []).length})</h3>
|
||||
<div style="padding: 10px; background: #171717; font-family: monospace; color: orange; font-size: 0.8rem; border-radius: 10px; position: relative;">
|
||||
${JSON.stringify((result.PolyPlus_BestFriends || []), null, 2)
|
||||
.replaceAll('\n','<br>')
|
||||
.replaceAll(' ', ' ')
|
||||
.replaceAll('\t', ' ')}
|
||||
<button class="btn btn-warning btn-sm" style="position: absolute; top: 0; right: 0; margin: 10px;" onclick="navigator.clipboard.writeText('${JSON.stringify((result.PolyPlus_BestFriends || []))}') .then(() => {alert('copied')}) .catch(() => {});">copy</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h3>Item Wishlist (${(result.PolyPlus_ItemWishlist || []).length})</h3>
|
||||
<div style="padding: 10px; background: #171717; font-family: monospace; color: orange; font-size: 0.8rem; border-radius: 10px; position: relative;">
|
||||
${JSON.stringify((result.PolyPlus_ItemWishlist || []), null, 2)
|
||||
.replaceAll('\n','<br>')
|
||||
.replaceAll(' ', ' ')
|
||||
.replaceAll('\t', ' ')}
|
||||
<button class="btn btn-warning btn-sm" style="position: absolute; top: 0; right: 0; margin: 10px;" onclick="navigator.clipboard.writeText('${JSON.stringify((result.PolyPlus_ItemWishlist || []))}') .then(() => {alert('copied')}) .catch(() => {});">copy</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
const SettingsURL = chrome.runtime.getURL('settings.html');
|
||||
const InExtensionSettings = window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash !== '#dev';
|
||||
const InExtensionSettings = window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash !== '#dev' && window.location.hash !== '#debug';
|
||||
if (InExtensionSettings === true) {
|
||||
window.location.href = SettingsURL + window.location.hash;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
{
|
||||
"matches": ["https://polytoria.com/my/settings/*"],
|
||||
"js": ["/js/settings.js", "/js/debug.js"],
|
||||
"js": ["/js/settings.js", "/js/extra-pages.js"],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
|
||||
|
|
|
|||
Reference in a new issue