Final Changes before Public Beta

This commit is contained in:
Index 2024-02-08 17:53:58 -06:00
parent 976cdfbf25
commit df14f2ea17
10 changed files with 129 additions and 111 deletions

View file

@ -1,4 +1,4 @@
> BETA Testing
> Public BETA Testing
# Poly+
Poly+ is an upcoming quality-of-life browser extension for the Polytoria website! The extension provides tons of improvements to improve your experience on Polytoria!

View file

@ -55,7 +55,7 @@ UpdateLocalData();
function UpdateLocalData() {
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
Settings = result.PolyPlus_Settings || {PinnedGamesOn: false}
Settings = result.PolyPlus_Settings || {PinnedGamesOn: true, BestFriendsOn: false}
});
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {

View file

@ -6,25 +6,10 @@ chrome.action.onClicked.addListener((tab) => {
});
// REGISTER AN ALARM FOR DAILY UPDATE CHECK
/*
chrome.alarms.create("PolyPlus-UpdateCheck", {
periodInMinutes: 24 * 60,
when: Date.now() + (12 - new Date().getHours()) * 60 * 60 * 1000,
});
*/
// Create a date object with the current date and the desired time
/*
var date = new Date();
date.setHours(19, 31, 0, 0); // 7:25 PM
// Create an alarm that fires at 7:25 PM and repeats every day
chrome.alarms.create("PolyPlus-UpdateCheck", {
periodInMinutes: 24 * 60,
when: date.getTime()
});
*/
// HANDLE ALARMS FIRING
chrome.alarms.onAlarm.addListener(function(alarm){
@ -78,6 +63,15 @@ chrome.contextMenus.create({
// HANDLE CONTEXT MENU ITEMS
chrome.contextMenus.onClicked.addListener(function (info, tab){
chrome.notifications.create({
type: "basic",
iconUrl: chrome.runtime.getURL("icon.png"),
title: "New Update Available",
message: "A new update is available for Poly+!",
}, function(id) {
console.log(id)
})
if (info.menuItemId === 'PolyPlus-CopyID') {
let ID = parseInt(info.linkUrl.split('/')[4])
chrome.scripting
@ -122,29 +116,3 @@ function CopyAvatarHash(hash) {
alert('Failure to copy avatar hash.')
});
}
function HandleJoinPlace(url) {
console.log('HANDLING JOINING PLACE')
const PlaceID = new URL(url).pathname.split('/')[2]
fetch('https://polytoria.com/api/places/join',{
method: 'POST',
body: {
placeID:PlaceID
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network not ok')
}
return response.json()
})
.then(data => {
if (data.success !== true) {throw new Error(data.message)}
window.location.href = 'polytoria://client/' + data.token
})
.catch(error => {console.log(error)})
}
export default {
hi: 1
}

View file

@ -8,7 +8,6 @@ const ExpectedSettings = {
IRLPriceWithCurrencyCurrency: 0,
IRLPriceWithCurrencyPackage: 0,
HideNotifBadgesOn: true,
SimplifiedProfileURLsOn: true,
StoreOwnTagOn: true,
ThemeCreatorOn: false,
ThemeCreator: {

View file

@ -26,18 +26,23 @@ let GamePinned;
RatingsContainer.children[0].appendChild(PercentageLabel)
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
Settings = result.PolyPlus_Settings;
Settings = result.PolyPlus_Settings || {
PinnedGamesOn: true,
InlineEditingOn: false,
GameProfilesOn: false
};
if (Settings.PinnedGamesOn === true) {
HandlePinnedGames()
}
// Disabled settings
if (Settings.InlineEditingOn === true || 1 === 1) {
// Work in Progress
if (Settings.InlineEditingOn === true) {
HandleInlineEditing()
}
if (Settings.GameProfilesOn === true && 1 === 2) {
// Work in Progress
if (Settings.GameProfilesOn === true) {
HandleGameProfiles()
}
});
@ -46,6 +51,7 @@ let GamePinned;
async function HandlePinnedGames() {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result){
PinnedGames = result.PolyPlus_PinnedGames || {};
/*
const PinBtn = document.createElement('button');
PinBtn.classList = 'btn btn-warning btn-sm';
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
@ -60,17 +66,45 @@ async function HandlePinnedGames() {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin (max 5/5)'
}
}
*/
const PinBtn = document.createElement('button');
PinBtn.classList = 'btn btn-warning btn-sm';
PinBtn.style = 'position: absolute; right: 0; margin-right: 7px;'
if (PinnedGames.includes(parseInt(GameID))) {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin';
} else {
if (PinnedGames.length !== 5) {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
} else {
PinBtn.setAttribute('disabled', true)
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin (max 5/5)'
}
}
PinBtn.addEventListener('click', function() {
PinBtn.setAttribute('disabled', 'true')
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
PinnedGames = result.PolyPlus_PinnedGames || {};
if (PinnedGames[GameID]) {
delete PinnedGames[GameID]
PinnedGames = result.PolyPlus_PinnedGames || [];
/*
const Index = PinnedGames.indexOf(parseInt(GameID))
if (Index !== -1) {
//delete PinnedGames[GameID]
PinnedGames.splice(Index, 1)
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
} else {
PinnedGames[GameID] = {lastVisited: new Date()}
//PinnedGames[GameID] = {lastVisited: new Date()}
PinnedGames.push(parseInt(GameID))
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
}
*/
const Index = PinnedGames.indexOf(parseInt(GameID));
if (Index !== -1) {
PinnedGames.splice(Index, 1);
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
} else {
PinnedGames.push(parseInt(GameID));
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
}
@ -83,13 +117,14 @@ async function HandlePinnedGames() {
});
});
document.querySelectorAll('.card-header')[2].appendChild(PinBtn);
document.getElementsByClassName('card-header')[2].appendChild(PinBtn);
chrome.storage.onChanged.addListener(function(changes, namespace) {
if ('PolyPlus_PinnedGames' in changes) {
chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) {
PinnedGames = result.PolyPlus_PinnedGames || {};
PinnedGames = result.PolyPlus_PinnedGames || [];
/*
if (PinnedGames[GameID]) {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
} else {
@ -101,6 +136,18 @@ async function HandlePinnedGames() {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin (max 5/5)'
}
}
*/
if (PinnedGames.includes(parseInt(GameID))) {
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Un-pin'
} else {
if (PinnedGames.length !== 5) {
PinBtn.removeAttribute('disabled')
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin'
} else {
PinBtn.setAttribute('disabled', true)
PinBtn.innerHTML = '<i class="fa-duotone fa-star"></i> Pin (max 5/5)'
}
}
});
}
});

View file

@ -5,21 +5,23 @@ var PurchaseBtn;
var WishlistBtn;
setTimeout(function () {
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
}
PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0]
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
}
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'))) {
HandleItemWishlist()
}
})
if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) {
console.log('AAAA')
HandleItemWishlist()
}
})
}, 100)
chrome.storage.onChanged.addListener(function(changes, namespace) {
@ -96,7 +98,7 @@ function IRLPrice() {
}
function HandleItemWishlist() {
const DescriptionText = document.getElementsByClassName('card-text')[0]
const DescriptionText = document.querySelector('.mcard .card-body:has(p)')
WishlistBtn = document.createElement('button')
chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){
ItemWishlist = result.PolyPlus_ItemWishlist || [];

View file

@ -73,7 +73,7 @@
{
"matches": ["https://polytoria.com/store/**"],
"js": ["/js/store/item-view.js", "/js/store/try-on.js"]
"js": ["/js/store/item-view.js"]
},
{

View file

@ -1,6 +1,13 @@
<html>
<head>
<title>Poly+ Settings</title>
<!-- META TAGS -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- TITLE -->
<title>Poly+ | Settings</title>
<!-- CSS -->
<link rel="stylesheet" href="https://c0.ptacdn.com/static/app.64aa42f6.css">
</head>
<body data-bs-theme="dark">
@ -328,7 +335,7 @@
</div>
</dialog>
<div id="page">
<p id="PinnedGames">
<p class="setting-container" id="PinnedGames">
<span>
Pinned Games (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="PinnedGamesOn">Toggle</button>
@ -336,7 +343,7 @@
<br>
<span class="desc">Pin your favorite games to the top of the homepage!</span>
</p>
<p id="ForumMentions">
<p class="setting-container" id="ForumMentions">
<span>
Forum Mentions (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ForumMentsOn">Toggle</button>
@ -344,7 +351,7 @@
<br>
<span class="desc">Get a quick link to the popular person everyone is talking about's profile!</span>
</p>
<p id="BestFriends">
<p class="setting-container" id="BestFriends">
<span>
Best Friends (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="BestFriendsOn">Toggle</button>
@ -352,7 +359,7 @@
<br>
<span class="desc">Prioritize the bestest of friends on applicable friend lists!</span>
</p>
<p id="ImprovedFriendLists">
<p class="setting-container" id="ImprovedFriendLists">
<span>
Improved Friend Lists (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ImprovedFrListsOn">Toggle</button>
@ -364,7 +371,7 @@
<span style="font-size: 0.8rem; color: orange;">* You can only remove up to 25 friends at once.</span>
</span>
</p>
<p id="IRLPriceWithCurrency">
<p class="setting-container" id="IRLPriceWithCurrency">
<span>
Show IRL price with Brick Count (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="IRLPriceWithCurrencyOn">Toggle</button>
@ -396,7 +403,7 @@
<option value="5">$99.99 USD</option>
</select>
</p>
<p id="HideNotifBadges">
<p class="setting-container" id="HideNotifBadges">
<span>
Hide Notification Badges (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="HideNotifBadgesOn">Toggle</button>
@ -404,7 +411,10 @@
<br>
<span class="desc">Hide the annoying red circles on the sidebar!</span>
</p>
<p id="SimplifiedProfileURLs">
<!--
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>
@ -412,7 +422,8 @@
<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 id="StoreOwnTag">
-->
<p class="setting-container" id="StoreOwnTag">
<span>
Show "OWNED" Tag on Store Main Page (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="StoreOwnTagOn">Toggle</button>
@ -420,7 +431,7 @@
<br>
<span class="desc">Quickly see if you own the item at a glance with a little tag in the top left corner of item cards on the main store page!</span>
</p>
<p id="ThemeCreator">
<p class="setting-container" id="ThemeCreator">
<span>
Theme Creator (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ThemeCreatorOn">Toggle</button>
@ -429,7 +440,7 @@
<br>
<span class="desc">Unleash your creativity and customize the Polytoria website to your liking! (this feature is still in development)</span>
</p>
<p id="MoreSearchFilters">
<p class="setting-container" id="MoreSearchFilters">
<span>
More Search Filters (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="MoreSearchFiltersOn">Toggle</button>
@ -437,7 +448,7 @@
<br>
<span class="desc">Easily find what you're looking for with more search filters side-wide! (this does not affect the main site search on the navbar)</span>
</p>
<p id="ApplyMembershipTheme">
<p class="setting-container" id="ApplyMembershipTheme">
<span>
Apply Membership Theme for <b>Free</b> (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ApplyMembershipThemeOn">Toggle</button>
@ -449,7 +460,10 @@
<option value="PlusDX">Plus Deluxe</option>
</select>
</p>
<p id="ForumMarkdown" style="display: none;">
<!--
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>
@ -459,7 +473,8 @@
Format forum posts to make them look epic!
</span>
</p>
<p id="MultiCancelOutTrades">
-->
<p class="setting-container" id="MultiCancelOutTrades">
<span>
Multi-Cancel Outbound Trades (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="MultiCancelOutTradesOns">Toggle</button>
@ -471,7 +486,7 @@
<span style="font-size: 0.8rem; color: orange;">* You can only cancel up to 10 trades at once.</span>
</span>
</p>
<p id="ModifyNav">
<p class="setting-container" id="ModifyNav">
<span>
Modify Navbar (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ModifyNavOn">Toggle</button>
@ -482,7 +497,7 @@
Customize the navbar to your liking!
</span>
</p>
<p id="ItemWishlist">
<p class="setting-container" id="ItemWishlist">
<span>
Item Wishlist (<span class="status">enabled</span>)
<button class="btn btn-warning btn-sm" data-setting="ItemWishlistOn">Toggle</button>
@ -492,7 +507,7 @@
Wishlist that item that you REALLY want!
</span>
</p>
<p id="HideUpgradeBtn">
<p class="setting-container" id="HideUpgradeBtn">
<span>
Hide Upgrade Button (<span class="status">disabled</span>)
<button class="btn btn-warning btn-sm" data-setting="HideUpgradeBtnOn">Toggle</button>

View file

@ -1,22 +1,7 @@
const SaveBtn = document.getElementById('Save')
const Elements = Array.from(document.getElementsByClassName('setting-container'))
var Settings;
var SaveBtn = document.getElementById('Save')
var Elements = [
document.getElementById("PinnedGames"),
document.getElementById("ForumMentions"),
document.getElementById("BestFriends"),
document.getElementById("ImprovedFriendLists"),
document.getElementById("IRLPriceWithCurrency"),
document.getElementById("HideNotifBadges"),
document.getElementById("SimplifiedProfileURLs"),
document.getElementById("StoreOwnTag"),
document.getElementById("ThemeCreator"),
document.getElementById("MoreSearchFilters"),
document.getElementById("ApplyMembershipTheme"),
document.getElementById("MultiCancelOutTrades"),
document.getElementById("ModifyNav"),
document.getElementById("ItemWishlist"),
document.getElementById("HideUpgradeBtn")
];
var ExpectedSettings = {
PinnedGamesOn: true,
ForumMentsOn: false,
@ -26,7 +11,6 @@ var ExpectedSettings = {
IRLPriceWithCurrencyCurrency: 0,
IRLPriceWithCurrencyPackage: 0,
HideNotifBadgesOn: false,
SimplifiedProfileURLsOn: true,
StoreOwnTagOn: true,
ThemeCreatorOn: false,
ThemeCreator: {
@ -41,7 +25,7 @@ var ExpectedSettings = {
ModifyNavOn: false,
ModifyNav: [
{
Label: "Play",
Label: "Places",
Link: "https://polytoria.com/places"
},
{
@ -69,7 +53,7 @@ var ExpectedSettings = {
HideUpgradeBtnOn: false
}
var ResetDefaultsModal = document.getElementById('ResetDefaults-Modal')
const ResetDefaultsModal = document.getElementById('ResetDefaults-Modal')
var ThemeCreatorModal = {
Modal: document.getElementById('ThemeCreator-Modal'),
Save: document.getElementById('ThemeCreator-Modal-Save'),
@ -105,7 +89,6 @@ Elements.forEach(element => {
if (Button) {
Button.addEventListener('click', function() {
console.log('button clicked!!!!')
ToggleSetting(Button.getAttribute('data-setting'), element)
});
}
@ -173,14 +156,18 @@ Elements.forEach(element => {
Array.from(ModalInputs).forEach(input => {
if (!(input.getAttribute('data-ignore') === 'true')) {
if (!(input.getAttribute('data-parent'))) {
if (Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] !== "undefined") {
if (Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] !== "undefined" && Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] !== undefined) {
input.value = Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')]
} else {
input.value = ''
}
} else {
let Parent = input.getAttribute('data-parent')
if (Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')] !== "undefined") {
if (Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')] !== "undefined" && Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')] !== undefined) {
if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)}
input.value = Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')]
} else {
input.value = ''
}
}
}