Items in Wishlist get Removed upon Purchase

- Items that are in your "Item Wishlist" will now be automatically removed when purchased. You can now also no longer add items to your "Item Wishlist" if you already own the item.

- Fixed issue with forgetting to remove simplified-profile.js from manifest.json after deleting the file

- Added all experimental settings to the settings page ("Game Profiles", "Inline Editing", "Forum Unix Timestamps")

- Removed commented out settings on the settings page

- Removed the "Handle" part of all function names (eg. "HandlePinnedGames()" -> "PinnedGames()")

- Moved profile/profile.js to account/profile.js

- You can now quickly copy a message to share your or somebody else's 3D avatar URL on profile pages.
This commit is contained in:
Index 2024-02-11 11:30:59 -06:00
parent 5f601f8c07
commit 46efc889e7
8 changed files with 136 additions and 97 deletions

View file

@ -1,6 +1,6 @@
HandleExpandMessages()
ExpandMessages()
function HandleExpandMessages() {
function ExpandMessages() {
const Messages = document.getElementById('messages')
for (let message of Messages.children) {

View file

@ -15,11 +15,11 @@ if (UserID && !isNaN(UserID)) {
}
if (Settings.IRLPriceWithCurrencyOn === true) {
HandleIRLPrice()
IRLPrice()
}
if (Settings.BestFriendsOn === true) {
HandleBestFriends()
BestFriends()
}
if (Settings.OutfitCostOn === true) {
@ -30,23 +30,23 @@ if (UserID && !isNaN(UserID)) {
AvatarRow.parentElement.style.marginTop = '10px'
CalculateButton.addEventListener('click', function(){
HandleOufitCost()
OutfitCost()
});
}
});
const AvatarIFrame = document.querySelector('[src^="/ptstatic"]')
const DropdownMenu = document.getElementsByClassName('dropdown-menu dropdown-menu-right')[0]
const CopyItem = document.createElement('a')
CopyItem.classList = 'dropdown-item text-primary'
CopyItem.classList.remove('text-danger')
CopyItem.classList.add('text-primary')
CopyItem.href = '#'
CopyItem.innerHTML = `
<i class="fa-duotone fa-book"></i>
Copy 3D Avatar URL
`
DropdownMenu.appendChild(CopyItem)
CopyItem.addEventListener('click', function(){
navigator.clipboard.writeText(AvatarIFrame.src)
.then(() => {
@ -56,6 +56,25 @@ if (UserID && !isNaN(UserID)) {
alert('Failure to copy 3D avatar URL.')
});
});
const ShareItem = document.createElement('a')
ShareItem.classList = 'dropdown-item text-warning'
ShareItem.href = '#'
ShareItem.innerHTML = `
<i class="fa-duotone fa-book"></i>
Share your 3D Avatar URL!
`
DropdownMenu.appendChild(ShareItem)
ShareItem.addEventListener('click', function(){
navigator.clipboard.writeText("Hey! Look at my Polytoria avatar in 3D [here](" + AvatarIFrame.src + ")!")
.then(() => {
alert('Successfully copied sharable 3D avatar URL!')
})
.catch(() => {
alert('Failure to copy sharable 3D avatar URL.')
});
});
} else if (UserID && UserID[0] === "@") {
const Username = window.location.pathname.split('/')[2].substring(1)
@ -80,7 +99,7 @@ if (UserID && !isNaN(UserID)) {
});
}
function HandleIRLPrice() {
function IRLPrice() {
const NetWorthElement = document.getElementsByClassName('float-end text-success')[0];
const NetWorth = parseInt(NetWorthElement.innerText.replace(/,/g, ''));
let IRL;
@ -118,7 +137,7 @@ function HandleIRLPrice() {
NetWorthElement.innerText = NetWorthElement.innerText + " ($" + IRL + " " + DISPLAY + ")"
}
function HandleBestFriends() {
function BestFriends() {
chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result){
BestFriends = result.PolyPlus_BestFriends || [];
@ -200,7 +219,7 @@ function HandleBestFriends() {
}
}
async function HandleOufitCost() {
async function OutfitCost() {
const AvatarCost = {
Total: 0,
Limiteds: 0,

View file

@ -8,15 +8,15 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
}
if (Settings.ForumMentsOn === true) {
HandleForumMentions()
ForumMentions()
}
if (Settings.ForumUnixStampsOn === true) {
HandleUnixTimestamps()
ForumUnixTimestamps()
}
});
function HandleForumMentions() {
function ForumMentions() {
const Regex = /@([\w.]+)/g
for (let text of ForumText) {
@ -30,7 +30,7 @@ function HandleForumMentions() {
}
}
function HandleUnixTimestamps() {
function ForumUnixTimestamps() {
const Regex = /&lt;t:[A-Za-z0-9]+&gt;/i
for (let text of ForumText) {

View file

@ -29,21 +29,20 @@ let PinnedGames;
Settings = result.PolyPlus_Settings;
if (Settings.PinnedGamesOn === true) {
HandlePinnedGames()
PinnedGames()
}
// Disabled settings
if (Settings.InlineEditingOn === true || 1 === 2) {
HandleInlineEditing()
if (Settings.InlineEditingOn === true) {
InlineEditing()
}
if (Settings.GameProfilesOn === true && 1 === 2) {
HandleGameProfiles()
if (Settings.GameProfilesOn === true) {
GameProfiles()
}
});
})()
async function HandlePinnedGames() {
async function PinnedGames() {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
PinnedGames = result.PolyPlus_PinnedGames || [];
const PinBtn = document.createElement('button');
@ -107,7 +106,7 @@ async function HandlePinnedGames() {
});
}
async function HandleInlineEditing() {
async function InlineEditing() {
// Fix description editing
// Make it possible to edit description even if the game doesn't initially have a description
// Add the ability to edit the game's genre
@ -202,7 +201,7 @@ async function HandleInlineEditing() {
const Data = JSON.parse('{"gameTitle": "Hyper[Fart]","bg": "#000","accent": "#007bff","secondary": "#","cardBg": "#313131","font": "","text": "#fff"}')
async function HandleGameProfiles(Data) {
async function GameProfiles(Data) {
document.querySelector('h1.my-0')
.setAttribute('game-key', 'true');
document.querySelector('div[style="min-height: 60vh;"]')

View file

@ -33,22 +33,22 @@ let GamePinned;
};
if (Settings.PinnedGamesOn === true) {
HandlePinnedGames()
PinnedGames()
}
// Work in Progress
if (Settings.InlineEditingOn === true) {
HandleInlineEditing()
InlineEditing()
}
// Work in Progress
if (Settings.GameProfilesOn === true) {
HandleGameProfiles()
GameProfiles()
}
});
})()
async function HandlePinnedGames() {
async function PinnedGames() {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
PinnedGames = result.PolyPlus_PinnedGames || {};
/*
@ -154,7 +154,7 @@ async function HandlePinnedGames() {
});
}
async function HandleInlineEditing() {
async function InlineEditing() {
// Fix description editing
// Make it possible to edit description even if the game doesn't initially have a description
// Add the ability to edit the game's genre
@ -320,7 +320,7 @@ async function HandleInlineEditing() {
const Data = JSON.parse('{"gameTitle": "Hyper[Fart]","bg": "#000","accent": "#007bff","secondary": "#","cardBg": "#313131","font": "","text": "#fff"}')
async function HandleGameProfiles(Data) {
async function GameProfiles(Data) {
document.querySelector('h1.my-0')
.setAttribute('game-key', 'true');
document.querySelector('div[style="min-height: 60vh;"]')

View file

@ -6,6 +6,7 @@ var Settings;
var ItemWishlist;
var PurchaseBtn;
var WishlistBtn;
var ItemOwned;
(async () => {
if (!(window.location.href.split('/')[4])) {return}
@ -13,14 +14,14 @@ var WishlistBtn;
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){
Settings = result.PolyPlus_Settings || {}
PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0]
PurchaseBtn = document.querySelector('.btn#purchase-button')
ItemOwned = (PurchaseBtn.innerText === ' Item owned' || document.querySelector('.btn[onclick="sellItem()"]') !== null)
if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() }
if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) {
if (Settings.ItemWishlistOn === true) {
HandleItemWishlist()
}
})
@ -74,7 +75,21 @@ function HandleItemWishlist() {
chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){
ItemWishlist = result.PolyPlus_ItemWishlist || [];
if (Array.isArray(ItemWishlist) && ItemWishlist.includes(parseInt(ItemID))) {
if (ItemOwned === true) {
if (ItemWishlist.includes(parseInt(ItemID))) {
ItemWishlist.splice(ItemWishlist.indexOf(parseInt(ItemID)), 1)
chrome.storage.sync.set({'PolyPlus_ItemWishlist': ItemWishlist, arrayOrder: true});
}
return
}
if (ItemOwned === true) {
return
} else if (ItemOwned === true && ItemWishlist.includes(parseInt(ItemID))) {
ItemWishlist.splice(ItemWishlist.indexOf(parseInt(ItemID)), 1)
return
}
if (ItemWishlist.includes(parseInt(ItemID))) {
WishlistBtn.classList = 'btn btn-danger btn-sm'
WishlistBtn.innerHTML = `
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Un-Wishlist Item

View file

@ -51,13 +51,7 @@
{
"matches": ["https://polytoria.com/users/**"],
"js": ["/js/profile/profile.js"]
},
{
"matches": ["https://polytoria.com/profile/**"],
"js": ["/js/profile/simplified-profile.js"],
"run_at": "document_start"
"js": ["/js/account/profile.js"]
},
{

View file

@ -132,18 +132,6 @@
</div>
<div class="modal-body">
<p>Unleash your creativity and customize the Polytoria website to your liking! (this feature is still in development)</p>
<!--
<div class="mx-auto" style="width: 450px; height: 350px; border: 2.5px solid #fff;">
<div class="row h-100">
<div class="col-md-1 h-100" style="padding: 25px; border-right: 2.5px solid #fff; padding-left: 0px !important;"></div>
<div class="col h-100" style="padding-left: 0px !important;">
<div style="padding: 10px; width: 100%; border-bottom: 2.5px solid #fff; margin-bottom: 3.5px"></div>
<h2 class="mb-1">Heading</h2>
<p>This is a preview!</p>
</div>
</div>
</div>
-->
<hr class="mt-2 mb-3">
<label>Save Theme to JSON</label>
@ -384,6 +372,7 @@
<br>
<span style="font-size: 0.8rem; color: orange;">* Currencies other than USD are purely approximations.</span>
</span>
<div role="group" class="input-group">
<select id="IRLPriceWithCurrencyCurrency" class="form-select form-select-sm mb-2" style="width:350px;" data-setting="IRLPriceWithCurrencyCurrency">
<option value="USD" selected>United States Dollar (USD)</option>
<option value="EUR">Euro (EUR)</option>
@ -394,15 +383,15 @@
<option value="TRY">Turkish Lira (TRY)</option>
<option value="BRL">Brazilian Real (BRL)</option>
</select>
<select id="IRLPriceWithCurrencyPackage" class="form-select form-select-sm mb-2" style="width:350px;" data-setting="IRLPriceWithCurrencyPackage">
<option value="0" selected>$0.99 USD</option>
<option value="1">$4.99 USD</option>
<option value="2">$9.99 USD</option>
<option value="3">$24.99 USD</option>
<option value="4">$49.99 USD</option>
<option value="5">$99.99 USD</option>
<option value="0" selected>$0.99 Brick Package</option>
<option value="1">$4.99 Brick Package</option>
<option value="2">$9.99 Brick Package</option>
<option value="3">$24.99 Brick Package</option>
<option value="4">$49.99 Brick Package</option>
<option value="5">$99.99 Brick Package</option>
</select>
</div>
</p>
<p class="setting-container" id="HideNotifBadges">
<span>
@ -412,18 +401,6 @@
<br>
<span class="desc">Hide the annoying red circles on the sidebar!</span>
</p>
<!--
No longer a setting
<p class="setting-container" id="SimplifiedProfileURLs">
<span>
Simplified Profile URLs (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="SimplifiedProfileURLsOn">Toggle</button>
</span>
<br>
<span class="desc">Makes all profile URLs simpler by allowing for you to go to "https://polytoria.com/profile/UsernameGoesHere" to redirect to the real profile URL!</span>
</p>
-->
<p class="setting-container" id="StoreOwnTag">
<span>
Show "OWNED" Tag on Store Main Page (<span class="status">enabled</span>)
@ -461,20 +438,6 @@
<option value="PlusDX">Plus Deluxe</option>
</select>
</p>
<!--
Forum markdown has been added officially
<p class="setting-container" id="ForumMarkdown">
<span>
Forum Markdown (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ForumMarkOn">Toggle</button>
</span>
<br>
<span class="desc">
Format forum posts to make them look epic!
</span>
</p>
-->
<p class="setting-container" id="MultiCancelOutTrades">
<span>
Multi-Cancel Outbound Trades (<span class="status">enabled</span>)
@ -516,6 +479,55 @@
<br>
<span class="desc">Hide the ugly blue "Upgrade" button on the sidebar!</span>
</p>
<p class="setting-container" id="OutfitCost">
<span>
Show Outfit Cost on Profiles (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="OutfitCostOn">Toggle</button>
</span>
<br>
<span class="desc">Quickly see how many bricks a user spent on their avatar!</span>
</p>
<div class="card">
<div class="card-body">
<h3>EXPERIMENTAL SETTINGS</h3>
<p>These features are a work in progress.</p>
<hr>
<p class="setting-container" id="GameProfiles">
<span>
Game Profiles (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="GameProfilesOn">Toggle</button>
</span>
<br>
<span class="desc">Traverse a place view page that matches a place's color palette!</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* Place creators must request a game profile for one to be made.</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* This feature will be expanded upon in the future.</span>
</p>
<p class="setting-container" id="InlineEditing">
<span>
Inline Editing (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="InlineEditingOn">Toggle</button>
</span>
<br>
<span class="desc">Quickly edit your asset's details such as name and description on the same page as viewing the asset!</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* This feature currently only supports places.</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* This feature is not finished or polished.</span>
</p>
<p class="setting-container" id="ForumUnixStamps">
<span>
Forum Unix Timestamps (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ForumUnixStampsOn">Toggle</button>
</span>
<br>
<span class="desc">See a date and time that is adjusted to everyone (who is using Poly+)'s local time</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* The styling for this feature is not yet done.</span>
</p>
</div>
</div>
<hr>
<button id="Save" class="btn btn-primary" disabled="true">Save</button>
<button id="ResetDefaults" class="btn btn-warning">Reset to Default Settings</button>