From 976cdfbf259bb29634f7bb9039e8337c45c8bb4e Mon Sep 17 00:00:00 2001 From: Index Date: Wed, 7 Feb 2024 17:06:33 -0600 Subject: [PATCH] February 8th is going to be a good day - New Icon - Moved avatar-sandbox.html and utils.js to /resources - Browser automatically allows resources to be used from the resources folder - Code Improvements - Deleted trick-or-treat.js - Bug Fixes --- icon.png | Bin 11350 -> 5409 bytes js/account/avatar-sandbox.js | 2 +- js/account/avatar-sandbox2.js | 2 +- js/account/home.js | 16 +- js/account/inventory.js | 8 +- js/forum/forum-view-old.js | 173 ---- js/forum/forum-view-old2.js | 63 -- js/forum/forum-view.js | 30 +- js/membership-themes.js | 7 +- js/places/place-join.js | 9 +- js/places/place-view.js | 9 +- js/places/place-view2.js | 313 +++++++ js/polyplus-settings.js | 867 ----------------- js/profile/profile.js | 138 +-- js/{account => resources}/avatar-sandbox.html | 0 js/{ => resources}/utils.js | 0 js/rewrites/everywhere2.js | 374 -------- js/rewrites/polyplus-settings.js | 883 ------------------ js/store/item-view.js | 253 ++--- js/trick-or-treat.js | 13 - manifest.json | 14 +- settings.html | 2 +- 22 files changed, 580 insertions(+), 2596 deletions(-) mode change 100755 => 100644 icon.png delete mode 100755 js/forum/forum-view-old.js delete mode 100755 js/forum/forum-view-old2.js create mode 100644 js/places/place-view2.js rename js/{account => resources}/avatar-sandbox.html (100%) rename js/{ => resources}/utils.js (100%) delete mode 100755 js/rewrites/everywhere2.js delete mode 100755 js/rewrites/polyplus-settings.js delete mode 100755 js/trick-or-treat.js diff --git a/icon.png b/icon.png old mode 100755 new mode 100644 index 13159982ece2cbd24da802117ecdfc1a71f199a8..2921c8a93b9909cf177a46504d40aad4317a0628 GIT binary patch literal 5409 zcmV++72fKJP)Px}+et)0RCr$PT?trJN4EY2L2(1aATA&-L@}<2OQJF?f(xL}iAIIEG48vFTbv|@ z#Fu#z(NTkmh;dLOj+#tjR74gfjK+NdC1ONn5e0)NMp1Ejp2Ex5(>8Q<_wCzFbL;!= zhe)mG{B`Qos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eT>EBOe}Sn?1cIUZTXlLdS(6ICpV332ghT zeK1e)Kw7m*`k{1)XEQw*tf+f{j=mPttazgn>hJF_Fc43Jz`OS#*wD@T407n;6RS2H zm;%og<>XA(N)9EWC|zg&P18Mpdt{Ccb}I<1zP((|iG@%%RM}$7e*XK9na<8mD!OO55N+Su8cWuw*x#KU@8Z(ZJz$P;n<NsV6<6Rsig z@e|xo;FQd&rSX0+D-sft3BcBkDW5)RvgX%D@RPG$Mzl?~1TB-1k$pjZ@Zb#8N~$UH zU$_!F?!Zg<1sJm+aQH72L$C)K9g{c=geZmF`fU4R=%!&gBSg}?{QUgdl;AYAzzk;R zz<~U`Ru9Tz-5c1g@#bF&wE^lO-S$>zS0-0^HK@O1wFQ*HMsvB*K3?8f2lU{Dy6 MlU9-{moR?!KLgY64*&oF diff --git a/js/account/avatar-sandbox.js b/js/account/avatar-sandbox.js index 42ec484..9615f8b 100755 --- a/js/account/avatar-sandbox.js +++ b/js/account/avatar-sandbox.js @@ -42,7 +42,7 @@ let ItemCardContents = ` if (new URLSearchParams(new URL(window.location).search).get('sandbox') === 'true') { console.log('Avatar Sandbox!') - LoadFile(chrome.runtime.getURL('js/account/avatar-sandbox.html'), function(html){ + LoadFile(chrome.runtime.getURL('js/resources/avatar-sandbox.html'), function(html){ PageContainer.innerHTML = html ItemGrid = document.getElementById('inventory') Wearing = document.getElementById('wearing') diff --git a/js/account/avatar-sandbox2.js b/js/account/avatar-sandbox2.js index ebad5e6..3968a77 100755 --- a/js/account/avatar-sandbox2.js +++ b/js/account/avatar-sandbox2.js @@ -46,7 +46,7 @@ let ItemCardContents = ` if (new URLSearchParams(new URL(window.location).search).get('sandbox') === 'true') { console.log('Avatar Sandbox!') - LoadFile(chrome.runtime.getURL('js/account/avatar-sandbox.html'), function(html){ + LoadFile(chrome.runtime.getURL('js/resources/avatar-sandbox.html'), function(html){ PageContainer.innerHTML = html ItemGrid = document.getElementById('inventory') Wearing = document.getElementById('wearing') diff --git a/js/account/home.js b/js/account/home.js index ea9f6c1..558df4e 100755 --- a/js/account/home.js +++ b/js/account/home.js @@ -49,13 +49,13 @@ let Spacer = document.createElement('div') Spacer.innerHTML = ' ' Spacer.style.width = '50px' Spacer.prepend(BestFriendsContainer) -FriendContainer.prepend(BestFriendsContainer) +FriendContainer.prepend(BestFriendsContainer) UpdateLocalData(); function UpdateLocalData() { chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { - Settings = result.PolyPlus_Settings + Settings = result.PolyPlus_Settings || {PinnedGamesOn: false} }); chrome.storage.sync.get(['PolyPlus_PinnedGames'], function(result) { @@ -93,7 +93,7 @@ function LoadPinnedGames() { } PinnedGames.forEach(element => { - fetch('https://api.polytoria.com/v1/places/:id'.replace(':id', element)) + fetch('https://api.polytoria.com/v1/places/' + element) .then(response => response.json()) .then(data => { let GameName = data.name; @@ -101,7 +101,7 @@ function LoadPinnedGames() { var NewGameContainer = document.createElement('a'); NewGameContainer.innerHTML = GameContainerElement.replace(':GameName',GameName).replace(':Thumbnail',GameThumbnail); - NewGameContainer.setAttribute('href', '/places/:id'.replace(':id',element)); + NewGameContainer.setAttribute('href', '/places/' + element); if (new Date().getDate() >= new Date(data.updatedAt).getDate()) { console.log('Game has updated') @@ -123,9 +123,13 @@ function LoadBestFriends() { }); if (BestFriends.length === 0) { - BestFriendsContainer.style.display = 'none' + BestFriendsContainer.style.visibility = 'hidden' + BestFriendsContainer.style.padding = '0px !important' + BestFriendsContainer.style.margin = '0px !important' } else { - BestFriendsContainer.style.display = '' + BestFriendsContainer.style.visibility = 'visible' + BestFriendsContainer.style.padding = '' + BestFriendsContainer.style.margin = '' } BestFriends.forEach(element => { diff --git a/js/account/inventory.js b/js/account/inventory.js index a57615b..e394c05 100755 --- a/js/account/inventory.js +++ b/js/account/inventory.js @@ -1,5 +1,5 @@ if (window.location.pathname.split('/')[3] === "inventory") { - let UserID = window.location.pathname.split('/')[2] + const UserID = window.location.pathname.split('/')[2] if (UserID === JSON.parse(window.localStorage.getItem('account_info')).ID) { let Nav = document.getElementsByClassName('nav-pills')[0] let WishlistNav = document.createElement('li') @@ -13,8 +13,8 @@ if (window.location.pathname.split('/')[3] === "inventory") { Nav.appendChild(WishlistNav) if (window.location.pathname.split('/')[4] === "wishlist") { - let ItemGrid = document.getElementsByClassName('itemgrid')[0] - let ItemCardContents = ` + const ItemGrid = document.getElementsByClassName('itemgrid')[0] + const ItemCardContents = `
:LimitedTag @@ -44,7 +44,7 @@ if (window.location.pathname.split('/')[3] === "inventory") { } }); WishlistNav.children[0].classList.add('active') - let Search = document.createElement('div') + const Search = document.createElement('div') Search.classList = 'row' Search.innerHTML = `
diff --git a/js/forum/forum-view-old.js b/js/forum/forum-view-old.js deleted file mode 100755 index f999098..0000000 --- a/js/forum/forum-view-old.js +++ /dev/null @@ -1,173 +0,0 @@ -var idCache = [] -let url = "https://polytoria.com/users/:id" - -console.log('loaded!') - -function LowAttentionSpanMode() { - let PostContent = document.querySelector('.mcard p:nth-child(3)').textContent - let Captions = CombineArray(PostContent.split(' ')).map((x, i) => `${x}`).join('') - let NumberOfCaptions = (PostContent.split(' ').length) - 1 - Swal.fire({ - title: "No Attention Span Mode", - html: ` - @$1'); - output = output.replace(/\n/g, '
'); - element.innerHTML = output - - let links = element.querySelectorAll('a.polyplus-mention'); - if (!(links.length > 3)) { - HandleLinks(links, null) - setTimeout(function () {}, 125) - } - }); - } -}); - -function HandleLinks(links, link, index = 0) { - if (index >= links.length) { - return - } - - link = links[index] - let username = link.textContent.replace(/@/g, '') - var inCache = CheckIDCache(username) - console.log(idCache, inCache) - if (inCache.success === false) { - fetch('https://api.polytoria.com/v1/users/find?username=:user'.replace(':user', username)) - .then(response => { - if (!response.ok) { - throw new Error(`An error occurred: ${response.status}`); - } - return response.json(); - }) - .then(data => { - link.setAttribute('href', url.replace(':id', data.id)); - idCache.push({ "username": username, "id": data.id }); - console.log(idCache); - HandleLinks(links, null, index + 1) - }) - .catch(error => { - console.error(error); - link.removeAttribute('href'); - HandleLinks(links, null, index + 1) - }); - } else { - console.log('cached') - link.setAttribute('href', url.replace(':id', inCache.id)) - HandleLinks(links, null, index + 1) - } -} - -function CheckIDCache(cache, username) { - idCache.forEach(element => { - if (element.username === username) { - return {"success": true, "id": element.id} - } - }); - /* - for (let i = 0; i < cache.length; i++) { - const element = cache[i]; - console.log((element.username === username)) - if (element.username === username) { - return {"success": true, "id": element.id}; - } - } - */ - return {"success": false, "id": null}; -} - -function MarkdownText(text) { - // Split the text into an array of lines - const lines = text.split('\n'); - - // Process each line - const formattedLines = lines.map(line => { - if (line.startsWith('###')) { - // Third-level heading: remove the '###' and wrap in

tag - const headingText = line.substring(3).trim(); - return `

${headingText}

`; - } else if (line.startsWith('##')) { - // Secondary heading: remove the '##' and wrap in

tag - const headingText = line.substring(2).trim(); - return `

${headingText}

`; - } else if (line.startsWith('#')) { - // Big heading: remove the '#' and wrap in

tag - const headingText = line.substring(1).trim(); - return `

${headingText}

`; - } else { - // Apply formatting to the line - let formattedLine = line.replace(/\*\*(.*?)\*\*/g, '$1'); // Bold - formattedLine = formattedLine.replace(/__(.*?)__/g, '$1'); // Underline - formattedLine = formattedLine.replace(/\*(.*?)\*/g, '$1'); // Italics - formattedLine = formattedLine.replace(/~~(.*?)~~/g, '$1'); // Strikethrough - return formattedLine; - } - }); - - // Join the formatted lines back into a single string - const formattedText = formattedLines.join('\n\n'); - - return formattedText; - } \ No newline at end of file diff --git a/js/forum/forum-view-old2.js b/js/forum/forum-view-old2.js deleted file mode 100755 index 41b62ac..0000000 --- a/js/forum/forum-view-old2.js +++ /dev/null @@ -1,63 +0,0 @@ -chrome.storage.sync.get(['PolyPlus'], function (result) { - if (result.PolyPlus.Settings.ForumMentsOn === false) { - return; - } - - const idCache = []; - const url = "https://polytoria.com/users/:id"; - const text = document.querySelectorAll('p.mb-0'); - - async function CheckIDCache(cache, username) { - for (let i = 0; i < cache.length; i++) { - const element = cache[i]; - console.log('type', typeof element); - console.log('expected type', typeof username); - - const cachedUsername = Object.keys(element)[0]; - if (cachedUsername.toString() === username) { - return [true, element]; - } - } - return [false, null]; - } - - async function processLinks(links) { - for (const link of links) { - const username = link.textContent.replace(/@/g, ''); - const inCache = await CheckIDCache(idCache, username); - console.log('1', inCache[0]); - console.log('2', inCache[1]); - - if (inCache[0] === false) { - console.log('not cached'); - try { - const response = await fetch(`https://api.polytoria.com/v1/users/find?username=${username}`); - if (!response.ok) { - throw new Error(`An error occurred: ${response.status}`); - } - const data = await response.json(); - link.setAttribute('href', url.replace(':id', data.id)); - idCache.push({ [username]: data.id }); - console.log(idCache); - } catch (error) { - console.error(error); - link.removeAttribute('href'); - } - } else { - console.log('cached'); - link.setAttribute('href', url.replace(':id', inCache[1][username])); - } - } - } - - text.forEach(element => { - let output = element.innerText.replace(/@([\w.]+)/g, '@$1'); - output = output.replace(/\n/g, '
'); - element.innerHTML = output; - - const links = element.querySelectorAll('a'); - if (!(links.length > 3)) { - processLinks(links); - } - }); -}); diff --git a/js/forum/forum-view.js b/js/forum/forum-view.js index 0acca90..f1abeee 100644 --- a/js/forum/forum-view.js +++ b/js/forum/forum-view.js @@ -2,13 +2,16 @@ const ForumText = document.querySelectorAll('p:not(.text-muted):not(.mb-0)') var Settings = [] chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { - Settings = result.PolyPlus_Settings || [] + Settings = result.PolyPlus_Settings || { + ForumMentsOn: false, + ForumUnixStampsOn: false + } - if (Settings.ForumMentsOn === true || 1 === 2) { + if (Settings.ForumMentsOn === true) { HandleForumMentions() } - if (1 === 1) { + if (Settings.ForumUnixStampsOn === true) { HandleUnixTimestamps() } }); @@ -21,27 +24,28 @@ function HandleForumMentions() { let match; while ((match = Regex.exec(text.innerText)) !== null) { const Username = match[0].substring(1) - FormattedText = FormattedText.replaceAll(match[0], `${match[0]}`) + FormattedText = FormattedText.replaceAll(match[0], `${match[0]}`) } text.innerHTML = FormattedText } } function HandleUnixTimestamps() { - const Regex = //gm - //const Regex = /<t:[A-Za-z0-9]+>/i + const Regex = /<t:[A-Za-z0-9]+>/i for (let text of ForumText) { - //let FormattedText = text.innerHTML + let FormattedText = text.innerHTML let match; - while ((match = Regex.exec(text.innerText)) !== null) { - console.log(match[0]) - const Timestamp = new Date(parseInt(match[0].substring(3).slice(0, -1))*1000) + + while ((match = Regex.exec(FormattedText)) !== null) { + const Timestamp = new Date(match[0].substring(6, match[0].length - 4) * 1000) const Months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] - const Result = `${Months[Timestamp.getMonth()]} ${Timestamp.getDate()}, ${Timestamp.getFullYear()}` - text.innerHTML = text.innerText.replaceAll(Regex.exec(text.innerText)[0], Result) + const Distance = new Intl.RelativeTimeFormat({numeric: 'auto', style: 'short'}).format(Math.floor((Timestamp - new Date()) / (60 * 1000)), 'day') + const Result = `${Months[Timestamp.getMonth()]} ${Timestamp.getDate()}, ${Timestamp.getFullYear()} (${["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"][Timestamp.getDay()-1]}) at ${Timestamp.getHours()-12}:${String(Timestamp.getMinutes()).padStart(2, "0")} (${Distance})` + FormattedText = FormattedText.replaceAll(match[0], Result) + console.log(FormattedText) } - //text.innerHTML = FormattedText + text.innerHTML = FormattedText } } \ No newline at end of file diff --git a/js/membership-themes.js b/js/membership-themes.js index ee67a76..ebc8154 100755 --- a/js/membership-themes.js +++ b/js/membership-themes.js @@ -1,7 +1,10 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){ - Settings = result.PolyPlus_Settings || []; - + Settings = result.PolyPlus_Settings || { + ApplyMembershipThemeOn: false, + ApplyMembershipThemeTheme: 0 + }; if (Settings.ApplyMembershipThemeOn !== true) {return} + MembershipTheme = Settings.ApplyMembershipThemeTheme === 0 ? 'plus': 'plusdx' document.addEventListener('DOMContentLoaded', function(){ diff --git a/js/places/place-join.js b/js/places/place-join.js index 2614110..3f732e7 100644 --- a/js/places/place-join.js +++ b/js/places/place-join.js @@ -1,7 +1,10 @@ -!(() => { - const PlaceID = parseInt(window.location.pathname.split('/')[2]) +/* + DISABLED FEATURE +*/ - console.log('PLACE ID: ' + PlaceID) +!(() => { + return + const PlaceID = parseInt(window.location.pathname.split('/')[2]) fetch('https://polytoria.com/home') .then(response => { diff --git a/js/places/place-view.js b/js/places/place-view.js index af29130..96359f5 100755 --- a/js/places/place-view.js +++ b/js/places/place-view.js @@ -7,7 +7,6 @@ let PinnedGames; !(() => { if (GameID === undefined) {return} - /* const DataContainer = document.getElementById('likes-data-container') const RatingsData = { Likes: parseInt(DataContainer.getAttribute('data-like-count')), @@ -25,7 +24,6 @@ let PinnedGames; PercentageLabel.innerText = RatingsData.Percentage + '%' RatingsContainer.children[0].appendChild(PercentageLabel) - */ chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { Settings = result.PolyPlus_Settings; @@ -55,7 +53,12 @@ async function HandlePinnedGames() { if (PinnedGames.includes(parseInt(GameID))) { PinBtn.innerHTML = ' Un-pin'; } else { - PinBtn.innerHTML = ' Pin'; + if (PinnedGames.length !== 5) { + PinBtn.innerHTML = ' Pin' + } else { + PinBtn.setAttribute('disabled', true) + PinBtn.innerHTML = ' Pin (max 5/5)' + } } PinBtn.addEventListener('click', function() { diff --git a/js/places/place-view2.js b/js/places/place-view2.js new file mode 100644 index 0000000..b51adfe --- /dev/null +++ b/js/places/place-view2.js @@ -0,0 +1,313 @@ +let GameID = window.location.pathname.split('/')[2] + +var Settings; +let PinnedGames; +let GamePinned; + +!(() => { + if (GameID === undefined) {return} + + const DataContainer = document.getElementById('likes-data-container') + const RatingsData = { + Likes: parseInt(DataContainer.getAttribute('data-like-count')), + Dislikes: parseInt(DataContainer.getAttribute('data-dislike-count')), + Percentage: null + } + RatingsData.Percentage = Math.floor((RatingsData.Likes / (RatingsData.Likes + RatingsData.Dislikes)) * 100) + const RatingsContainer = document.getElementById('thumbup-btn').parentElement.parentElement + + const PercentageLabel = document.createElement('small') + PercentageLabel.classList = 'text-muted' + PercentageLabel.style.fontSize = '0.8rem' + PercentageLabel.style.marginLeft = '10px' + PercentageLabel.style.marginRight = '10px' + PercentageLabel.innerText = RatingsData.Percentage + '%' + + RatingsContainer.children[0].appendChild(PercentageLabel) + + chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { + Settings = result.PolyPlus_Settings; + + if (Settings.PinnedGamesOn === true) { + HandlePinnedGames() + } + + // Disabled settings + if (Settings.InlineEditingOn === true || 1 === 1) { + HandleInlineEditing() + } + + if (Settings.GameProfilesOn === true && 1 === 2) { + HandleGameProfiles() + } + }); +})() + +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;' + + if (PinnedGames[GameID]) { + PinBtn.innerHTML = ' Un-pin'; + } else { + if (PinnedGames.length !== 5) { + PinBtn.innerHTML = ' Pin' + } else { + PinBtn.setAttribute('disabled', true) + PinBtn.innerHTML = ' 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] + PinBtn.innerHTML = ' Pin' + } else { + PinnedGames[GameID] = {lastVisited: new Date()} + PinBtn.innerHTML = ' Un-pin' + } + + chrome.storage.sync.set({ 'PolyPlus_PinnedGames': PinnedGames, arrayOrder: true }, function() { + setTimeout(function() { + PinBtn.removeAttribute('disabled') + console.log(PinnedGames) + }, 1250) + }); + }); + }); + + document.querySelectorAll('.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 || {}; + + if (PinnedGames[GameID]) { + PinBtn.innerHTML = ' Un-pin' + } else { + if (PinnedGames.length !== 5) { + PinBtn.removeAttribute('disabled') + PinBtn.innerHTML = ' Pin' + } else { + PinBtn.setAttribute('disabled', true) + PinBtn.innerHTML = ' Pin (max 5/5)' + } + } + }); + } + }); + }); +} + +async function HandleInlineEditing() { + // 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 + // Improve editing visuals overall + + const GameCreator = document.querySelector('#main-content .card-body .col div.text-muted a[href^="/users/"]').getAttribute('href').split('/')[2] + console.log(GameCreator) + console.log(JSON.parse(window.localStorage.getItem('account_info')).ID) + if (GameCreator !== JSON.parse(window.localStorage.getItem('account_info')).ID) { + return + } + + let Editing = false + + const Style = document.createElement('style') + Style.innerHTML = ` + body[data-polyplus-inlineEditing="true"] .polyplus-inlineEditing-visible {display: block !important;} + .polyplus-inlineEditing-visible {display: none;} + + body[data-polyplus-inlineEditing="true"] .polyplus-inlineEditing-hidden {display: none !important;} + .polyplus-inlineEditing-hidden {display: block;} + ` + document.body.prepend(Style) + + const Inputs = [ + { + name: "name", + element: null, + reference: '.card-header h1[style="font-weight:800;font-size:1.6em"]', + placeholder: "Place Title..", + required: true, + isTextarea: false, + styles: 'font-weight:800;font-size:1.6em' + }, + { + name: "description", + element: null, + reference: '.col:has(#likes-data-container) .card.mcard.mb-2 .card-body.p-3.small', + placeholder: "Place Description..", + required: false, + isTextarea: true, + styles: 'height:300px; overflow-y:auto;' + } + ] + console.log(Inputs) + for (let input of Inputs) { + let Input = (input.isTextarea === true) ? document.createElement('textarea') : document.createElement('input') + input.element = Input + + const Reference = document.querySelector(input.reference) + + Input.classList = 'polyplus-inlineEditing-visible form-control' + Input.placeholder = input.placeholder + Input.value = Reference.innerText + Input.style = input.styles + + Reference.classList.add('polyplus-inlineEditing-hidden') + Reference.parentElement.appendChild(Input) + } + + const PlaceGenre = document.getElementsByClassName('list-unstyled m-0 col')[0].children[3] + + const Genres = [ + "other", + "adventure", + "building", + "competitive", + "creative", + "fighting", + "funny", + "hangout", + "medieval", + "parkour", + "puzzle", + "racing", + "roleplay", + "sandbox", + "showcase", + "simulator", + "sports", + "strategy", + "survival", + "techdemo", + "trading", + "tycoon", + "western" + ] + + const EditBtn = document.createElement('button'); + EditBtn.classList = 'btn btn-primary btn-sm'; + EditBtn.style = 'position: absolute; right: 0; margin-right: 7px;' + EditBtn.innerHTML = ' Edit Details' + document.getElementsByClassName('card-header')[3].appendChild(EditBtn); + + EditBtn.addEventListener('click', function(){ + Editing = !Editing + + EditBtn.children[0].classList.toggle('fa-hammer') + EditBtn.children[0].classList.toggle('fa-check-double') + EditBtn.children[0].classList.toggle('fa-fade') + + document.body.setAttribute('data-polyplus-inlineEditing', Editing) + + if (Editing === false) { + const Send = new FormData() + Send.append("_csrf", document.querySelector('input[name="_csrf"]').value) + Send.append("id", GameID) + for (let input of Inputs) { + console.log('start of loop') + Send.append(input.name, input.element.value) + } + + console.log('after') + fetch('/create/place/update', {method:"POST",body:Send}) + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.text() + }) + .then(data => { + console.log('Successfully edited game') + for (let input of Inputs) { + const Reference = document.querySelector(input.reference) + Reference.innerText = input.element.value + } + }) + .catch(error => { + alert('Error while saving changes') + console.log('Error while editing game') + }); + } + + /* + PlaceTitleSpan.setAttribute('contenteditable', Editing.toString()) + if (PlaceDesc !== null) { + console.log('Description exists') + PlaceDesc.setAttribute('contenteditable', Editing.toString()) + } + if (Editing === false) { + const Send = new FormData() + Send.append("_csrf", document.querySelector('input[name="_csrf"]').value) + Send.append("id", GameID) + Send.append("name", PlaceTitle.innerText || '') + + fetch('/create/place/update', {method:"POST",body:Send}) + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.text() + }) + .then(data => { + console.log('Successfully edited game') + }) + .catch(error => { + console.log('Error while editing game') + }); + } + */ + }); +} + +const Data = JSON.parse('{"gameTitle": "Hyper[Fart]","bg": "#000","accent": "#007bff","secondary": "#","cardBg": "#313131","font": "","text": "#fff"}') + +async function HandleGameProfiles(Data) { + document.querySelector('h1.my-0') + .setAttribute('game-key', 'true'); + document.querySelector('div[style="min-height: 60vh;"]') + .id = 'gameprofile'; + + const Style = document.createElement('style') + + Style.innerHTML = ` + div#app { + background: ${Data.bg} !important; + } + + #gameprofile { + /*font-family: ${Data.font} !important;*/ + color: ${Data.text} !important; + } + + #gameprofile .card { + --bs-card-bg: ${Data.cardBg}; + } + + /* + #gameprofile .card.mcard[game-key] .card-header { + background: transparent; + border: none; + } + */ + + #gameprofile .card.mcard [game-key] { + background: linear-gradient(to bottom, ${Data.accent}, ${Data.secondary}); + background-clip: text; + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + } + ` + document.body.appendChild(Style) +} \ No newline at end of file diff --git a/js/polyplus-settings.js b/js/polyplus-settings.js index 847012c..c8ea396 100755 --- a/js/polyplus-settings.js +++ b/js/polyplus-settings.js @@ -22,871 +22,4 @@ document.addEventListener('DOMContentLoaded', function(){ ` Nav.insertBefore(PolyPlusItem, Nav.getElementsByTagName('hr')[0]) - - return - if (window.location.pathname.split('/')[3] === "polyplus") { - console.log('is settings') - PolyPlusItem.classList.add('active') - document.getElementsByClassName('col-lg-10')[0].innerHTML = ` - - - - - - - - - - - - - -
-

- - Pinned Games (enabled) - - -
- Pin your favorite games to the top of the homepage! -

-

- - Forum Mentions (disabled) - - -
- Get a quick link to the popular person everyone is talking about's profile! -

-

- - Best Friends (enabled) - - -
- Prioritize the bestest of friends on applicable friend lists! -

-

- - Improved Friend Lists (enabled) - - -
- - Accept or decline all friend requests with the click of a button or multi-remove existing friends! -
- * You can only remove up to 25 friends at once. -
-

-

- - Show IRL price with Brick Count (enabled) - - -
- - See the real life currency value along with Bricks across the site! -
- * Currencies were calculated on [DATE]. -
- * Currencies other than USD are purely approximations. -
- - - -

-

- - Hide Notification Badges (disabled) - - -
- Hide the annoying red circles on the sidebar! -

-

- - Simplified Profile URLs (enabled) - - -
- Makes all profile URLs simpler by allowing for you to go to "https://polytoria.com/profile/UsernameGoesHere" to redirect to the real profile URL! -

-

- - Show "OWNED" Tag on Store Main Page (enabled) - - -
- 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! -

-

- - Theme Creator (disabled) - - - -
- Unleash your creativity and customize the Polytoria website to your liking! (this feature is still in development) -

-

- - More Search Filters (enabled) - - -
- Easily find what you're looking for with more search filters side-wide! (this does not affect the main site search on the navbar) -

-

- - Apply Membership Theme for Free (disabled) - - -
- Ever want the fancy membership themes for completely free? Well now you can get apply them site-wide! - -

- -

- - Multi-Cancel Outbound Trades (enabled) - - -
- - Quickly cancel several out-bound trades (trades that you have sent) all at once -
- * You can only cancel up to 10 trades at once. -
-

-

- - Modify Navbar (disabled) - - - -
- - Customize the navbar to your liking! - -

-

- - Item Wishlist (enabled) - - -
- - Wishlist that item that you REALLY want! - -

-

- - Hide Upgrade Button (disabled) - - -
- Hide the ugly blue "Upgrade" button on the sidebar! -

-
- - -

made by Index

-
- `; - - const SaveBtn = document.getElementById('Save') - const 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") - ]; - const ExpectedSettings = { - PinnedGamesOn: true, - ForumMentsOn: false, - BestFriendsOn: true, - ImprovedFrListsOn: true, - IRLPriceWithCurrencyOn: true, - IRLPriceWithCurrencyCurrency: 0, - IRLPriceWithCurrencyPackage: 0, - HideNotifBadgesOn: false, - 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, - MultiCancelOutTradesOn: true, - ItemWishlistOn: true, - HideUpgradeBtnOn: false - } - - /* - const ResetDefaultsModal = document.getElementById('ResetDefaults-Modal') - const ThemeCreatorModal = { - Modal: document.getElementById('ThemeCreator-Modal'), - Save: document.getElementById('ThemeCreator-Modal-Save'), - BGColor: document.getElementById('ThemeCreator-Modal-BGColor'), - BGImage: document.getElementById('ThemeCreator-Modal-BGImage'), - BGImageSize: document.getElementById('ThemeCreator-Modal-BGImageSize'), - PrimaryTextColor: document.getElementById('ThemeCreator-Modal-PrimaryTextColor'), - SecondaryTextColor: document.getElementById('ThemeCreator-Modal-SecondaryTextColor'), - LinkTextColor: document.getElementById('ThemeCreator-Modal-LinkTextColor'), - WebsiteLogo: document.getElementById('ThemeCreator-Modal-WebsiteLogo') - } - var ModifyNavModal = { - Modal: document.getElementById('ModifyNav-Modal'), - Save: document.getElementById('ModifyNav-Modal-Save'), - "1Label": document.getElementById('ModifyNav-Modal-1Label'), - "1Link": document.getElementById('ModifyNav-Modal-1Link'), - "2Label": document.getElementById('ModifyNav-Modal-2Label'), - "2Link": document.getElementById('ModifyNav-Modal-2Link'), - "3Label": document.getElementById('ModifyNav-Modal-3Label'), - "3Link": document.getElementById('ModifyNav-Modal-3Link'), - "4Label": document.getElementById('ModifyNav-Modal-4Label'), - "4Link": document.getElementById('ModifyNav-Modal-4Link'), - "5Label": document.getElementById('ModifyNav-Modal-5Label'), - "5Link": document.getElementById('ModifyNav-Modal-5Link'), - } - */ - SaveBtn.addEventListener("click", function() {Save()}); - Elements.forEach(element => { - let Button = element.getElementsByTagName('button')[0] - let Options = element.getElementsByTagName('button')[1] - let Select = element.getElementsByTagName('select') || [] - - if (Button) { - Button.addEventListener('click', function() { - console.log('button clicked!!!!') - ToggleSetting(Button.getAttribute('data-setting'), element) - }); - } - - if (Options) { - Options.addEventListener('click', function() { - let Modal = document.getElementById(Options.getAttribute('data-modal') + '-Modal') - let ModalButtons = Modal.getElementsByTagName('button') - let ModalInputs = Modal.getElementsByTagName('input') - let ModalSelect = Modal.getElementsByTagName('select') - - Array.from(ModalButtons).forEach(btn => { - if (!(btn.getAttribute('data-ignore') === 'true')) { - btn.addEventListener('click', function(){ - let Setting = btn.getAttribute('data-setting') - if (Setting === '[save]') { - Array.from(ModalInputs).forEach(input => { - if (!(input.getAttribute('data-ignore') === 'true')) { - if (!(input.getAttribute('data-parent'))) { - Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] = input.value || null - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')] = input.value || null - } - } - }); - Array.from(ModalSelect).forEach(select => { - if (!(select.getAttribute('data-ignore') === 'true')) { - if (!(select.getAttribute('data-parent'))) { - Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] = select.selectedIndex - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] = select.selectedIndex - } - } - }); - Save(); - setTimeout(function () { - LoadCurrent(); - Modal.close(); - }, 400) - } else if (Setting === '[cancel]') { - Modal.close(); - } else { - if (!(btn.getAttribute('data-parent'))) { - ToggleSetting(Modal.getAttribute('data-setting')[btn.getAttribute('data-setting')], null) - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - ToggleSetting(Modal.getAttribute('data-setting')[Parent][btn.getAttribute('data-setting')], null) - } - } - }); - } - }); - - 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") { - input.value = Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] - } - } else { - let Parent = input.getAttribute('data-parent') - if (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')] - } - } - } - }); - - Array.from(ModalSelect).forEach(select => { - if (!(select.getAttribute('data-ignore') === 'true')) { - if (!(select.getAttribute('data-parent'))) { - if (Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] !== "undefined") { - select.selectedIndex = Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] - } - } else { - let Parent = input.getAttribute('data-parent') - if (Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] !== "undefined") { - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - select.selectedIndex = Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] - } - } - } - }); - - Modal.showModal() - }); - } - - if (Select.length > 0) { - Array.from(Select).forEach(element => { - element.addEventListener('change', function() { - SetSetting(element.getAttribute('data-setting'), element, element.selectedIndex) - }); - }); - } - }); - document.getElementById('ResetDefaults').addEventListener('click', function() { - ResetDefaultsModal.showModal(); - }); - document.getElementById('ResetDefaults-Modal-Yes').addEventListener('click', function() { - Settings = ExpectedSettings - Save() - setTimeout(function () { - LoadCurrent(); - ResetDefaultsModal.close(); - }, 400) - }); - document.getElementById('ResetDefaults-Modal-No').addEventListener('click', function() { - ResetDefaultsModal.close(); - }); - - function LoadCurrent() { - chrome.storage.sync.get(["PolyPlus_Settings"], function(result) { - Settings = MergeObjects(result.PolyPlus_Settings || ExpectedSettings, ExpectedSettings) - - console.log(Settings) - - Elements.forEach(element => { - let Status = element.getElementsByClassName('status')[0] - console.log(element, FormatBool(Settings[element.getElementsByTagName('button')[0].getAttribute('data-setting')])) - Status.innerText = FormatBool(Settings[element.getElementsByTagName('button')[0].getAttribute('data-setting')]) - let SelectInput = element.getElementsByTagName('select')[0] - if (SelectInput) { - SelectInput.selectedIndex = Settings[SelectInput.getAttribute('data-setting')] - } - }); - }); - } - LoadCurrent(); - - function ToggleSetting(Name, Element) { - if (Settings[Name] === true) { - Settings[Name] = false; - } else { - Settings[Name] = true; - } - - if (Element != null) { - Element.getElementsByClassName('status')[0].innerText = FormatBool(Settings[Name]) - } - if (SaveBtn.getAttribute('disabled')) { - SaveBtn.removeAttribute('disabled') - } - } - - function SetSetting(Name, Element, Value) { - console.log(Settings) - Settings[Name] = Value - - if (SaveBtn.getAttribute('disabled')) { - SaveBtn.removeAttribute('disabled') - } - } - - function Save() { - SaveBtn.setAttribute('disabled', 'true') - window.localStorage.setItem('PolyPlusSettings', JSON.stringify(Settings)) - chrome.storage.sync.set({ 'PolyPlus_Settings': Settings, arrayOrder: true }, function() { - console.log('Saved successfully!'); - }); - - console.log(Settings); - } - - let LoadThemeFromJSONBtn = document.getElementById('LoadThemeFromJSONBtn') - let SaveThemeToJSONInput = document.getElementById('SaveThemeToJSONInput') - let CopyThemeJSONBtn = document.getElementById('CopyThemeJSONBtn') - LoadThemeFromJSONBtn.addEventListener('click', function(){ - LoadThemeJSON(LoadThemeFromJSONBtn.previousElementSibling.value) - }); - document.getElementById('ThemeCreator').getElementsByTagName('button')[1].addEventListener('click', function(){ - SaveThemeToJSONInput.value = JSON.stringify(Settings.ThemeCreator) - }); - CopyThemeJSONBtn.addEventListener('click', function(){ - if (SaveThemeToJSONInput.value.length > 0) { - navigator.clipboard.writeText(SaveThemeToJSONInput.value) - } - }); - - let CurrencyDate = LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){ - CurrencyDate = new Date(JSON.parse(text).Date).toLocaleDateString("en-US", {day:"numeric",month:"long",year:"numeric"}) - - document.getElementById('IRLPriceWithCurrencyCurrency').previousElementSibling.children[1].innerText = document.getElementById('IRLPriceWithCurrencyCurrency').previousElementSibling.children[1].innerText.replace('[DATE]', CurrencyDate) - }) - - function LoadThemeJSON(string) { - 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() - Settings.ThemeCreator = MergeObjects(JSONTable, ExpectedSettings.ThemeCreator) - Save(); - console.log(JSONTable.length, JSONTable, 'applied') - document.getElementById('ThemeCreator').getElementsByTagName('button')[1].click(); - } - } else { - alert('JSON is not a theme!') - //LoadThemeFromJSONBtn.innerText = 'JSON is too short or too long!' - //setTimeout(function () {LoadThemeFromJSONBtn.innerText = 'Load'}, 1250) - } - } catch (error) { - alert('JSON is invalid!') - //LoadThemeFromJSONBtn.innerText = 'JSON is invalid!' - //setTimeout(function () {LoadThemeFromJSONBtn.innerText = 'Load'}, 1250) - } - } - - /* - 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]; - } else if (obj1[key] !== obj2[key]) { - mergedObj[key] = obj2[key]; - } - } - - // Remove keys from mergedObj if they are not present in obj2 - for (var key in mergedObj) { - if (!obj2.hasOwnProperty(key)) { - delete mergedObj[key]; - } - } - - return mergedObj; - } - */ - - 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; - } - - function FormatBool(bool){ - if (bool === true) { - return 'enabled' - } else { - return 'disabled' - } - } - - function LoadFile(path, callback) { - var xhr = new XMLHttpRequest(); - xhr.onload = function () { return callback(this.responseText); } - xhr.open("GET", path, true); - xhr.send(); - } - } }); \ No newline at end of file diff --git a/js/profile/profile.js b/js/profile/profile.js index 9dfacf1..a6bf264 100755 --- a/js/profile/profile.js +++ b/js/profile/profile.js @@ -1,12 +1,18 @@ -setTimeout(function() {}, 100); -let URLSplit = window.location.pathname.split('/'); -let UserID = URLSplit[2]; +const UserID = window.location.pathname.split('/')[2]; +const AvatarRow = document.getElementsByClassName('d-flex flex-row flex-nowrap overflow-x-scroll px-3 px-lg-0 mb-2 mb-lg-0')[0] + var Settings; var BestFriends; -var FavoriteBtn; +let FavoriteBtn; +let CalculateButton; + if (UserID) { chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { - Settings = result.PolyPlus_Settings; + Settings = result.PolyPlus_Settings || { + IRLPriceWithCurrencyOn: false, + BestFriendsOn: false, + OutfitCostOn: true + } if (Settings.IRLPriceWithCurrencyOn === true) { HandleIRLPrice() @@ -16,29 +22,43 @@ if (UserID) { HandleBestFriends() } - if (1 === 1) { - HandleOufitCost() - } - }); - - // Update the local pinned games whenever the 'PinnedGames' array is updated - chrome.storage.onChanged.addListener(function(changes, namespace) { - if ('PolyPlus_BestFriends' in changes) { - chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) { - BestFriends = result.PolyPlus_BestFriends || []; - - if (!(BestFriends.length === 7)) { - if (Array.isArray(BestFriends) && BestFriends.includes(parseInt(UserID))) { - FavoriteBtn.innerText = 'Remove Best Friend Status' - } else { - FavoriteBtn.innerText = 'Best Friend' - } - } else { - FavoriteBtn.innerText = 'Remove Best Friend Status (max 7/7)' - } + if (Settings.OutfitCostOn === true) { + CalculateButton = document.createElement('button') + CalculateButton.classList = 'btn btn-warning btn-sm' + CalculateButton.innerText = 'Calculate Avatar Cost' + AvatarRow.parentElement.parentElement.prepend(CalculateButton) + AvatarRow.parentElement.style.marginTop = '10px' + + CalculateButton.addEventListener('click', function(){ + HandleOufitCost() }); } - }); + }); + + 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 = ` + + Copy 3D Avatar URL + ` + DropdownMenu.appendChild(CopyItem) + CopyItem.addEventListener('click', function(){ + navigator.clipboard.writeText(AvatarIFrame.src) + .then(() => { + alert('Successfully copied 3D avatar URL!') + }) + .catch(() => { + alert('Failure to copy 3D avatar URL.') + }); + }); + + /* + Way overcomplicated code when there is literally an iframe on the page with the exact same result const UserID = window.location.pathname.split('/')[2] const DefaultAvatar = { @@ -118,6 +138,7 @@ if (UserID) { }); Original.parentElement.appendChild(Clone) + */ } function HandleIRLPrice() { @@ -162,7 +183,6 @@ function HandleBestFriends() { chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result){ BestFriends = result.PolyPlus_BestFriends || []; - console.log('Best friends is enabled!') FavoriteBtn = document.createElement('button'); FavoriteBtn.classList = 'btn btn-warning btn-sm ml-2'; if (!(BestFriends.length === 7)) { @@ -184,13 +204,13 @@ function HandleBestFriends() { document.querySelectorAll('.section-title.px-3.px-lg-0.mt-3')[0].appendChild(FavoriteBtn); function Fav(UserID, btn) { - if (UserID === JSON.parse(window.localStorage.getItem('account_info')).ID) { - return - } + if (UserID === JSON.parse(window.localStorage.getItem('account_info')).ID) { return } btn.setAttribute('disabled', 'true') + chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) { const BestFriends = result.PolyPlus_BestFriends || []; const index = BestFriends.indexOf(parseInt(UserID)); + if (index !== -1) { // Number exists, remove it BestFriends.splice(index, 1); @@ -211,33 +231,42 @@ function HandleBestFriends() { }); }); } + }); - function ClearFavs(){ - chrome.storage.sync.set({ 'PolyPlus': {"PinnedGames": pinnedGames, "BestFriends": []}, arrayOrder: true }, function() { - console.log('BestFriends saved successfully!'); - setTimeout(function() { - btn.removeAttribute('disabled') - }, 1500) - }); - } - - function ClearFavsOld(){ - chrome.storage.sync.set({ 'PolyPlus': {"PinnedGames": pinnedGames, "BestFriends": []}, arrayOrder: true }, function() { - console.log('BestFriends saved successfully!'); - setTimeout(function() { - btn.removeAttribute('disabled') - }, 1500) + chrome.storage.onChanged.addListener(function(changes, namespace) { + if ('PolyPlus_BestFriends' in changes) { + chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) { + BestFriends = result.PolyPlus_BestFriends || []; + + if (!(BestFriends.length === 7)) { + if (Array.isArray(BestFriends) && BestFriends.includes(parseInt(UserID))) { + FavoriteBtn.innerText = 'Remove Best Friend Status' + } else { + FavoriteBtn.innerText = 'Best Friend' + } + } else { + FavoriteBtn.innerText = 'Remove Best Friend Status (max 7/7)' + } }); } }); + + function ClearBestFriends(){ + chrome.storage.sync.set({ 'PolyPlus_BestFriends': {"BestFriends": []}, arrayOrder: true }, function() { + console.log('BestFriends saved successfully!'); + setTimeout(function() { + btn.removeAttribute('disabled') + }, 1500) + }); + } } async function HandleOufitCost() { - const AvatarRow = document.getElementsByClassName('d-flex flex-row flex-nowrap overflow-x-scroll px-3 px-lg-0 mb-2 mb-lg-0')[0] - - let TotalCost = 0 - let Limiteds = 0 - let Exclusives = 0 + const AvatarCost = { + Total: 0, + Limiteds: 0, + Exclusives: 0 + } for (let item of AvatarRow.children) { const ItemID = item.getElementsByTagName('a')[0].href.split('/')[4] await fetch('https://api.polytoria.com/v1/store/'+ItemID) @@ -250,14 +279,14 @@ async function HandleOufitCost() { .then(data => { let Price = data.price if (data.isLimited === true) { - Limiteds += 1 + AvatarCost.Limiteds += 1 Price = data.averagePrice } else if (data.sales === 0) { - Exclusives += 1 + AvatarCost.Exclusives += 1 Price = 0 } - TotalCost += Price + AvatarCost.Total += Price }) .catch(error => {console.log(error)}); } @@ -265,8 +294,7 @@ async function HandleOufitCost() { const TotalCostText = document.createElement('small') TotalCostText.classList = 'text-muted' TotalCostText.style.padding = '20px' - TotalCostText.innerHTML = `${ (Limiteds > 0 || Exclusives > 0) ? '~' : '' } ${TotalCost.toLocaleString()}${ (Limiteds > 0) ? ` (has ${Limiteds} limiteds)` : '' }${ (Exclusives > 0) ? ` (has ${Exclusives} exclusives)` : '' }` + TotalCostText.innerHTML = `${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' } ${AvatarCost.Total.toLocaleString()}${ (AvatarCost.Limiteds > 0) ? ` (has ${AvatarCost.Limiteds} limiteds)` : '' }${ (AvatarCost.Exclusives > 0) ? ` (has ${AvatarCost.Exclusives} exclusives)` : '' }` AvatarRow.parentElement.parentElement.prepend(TotalCostText) AvatarRow.parentElement.style.marginTop = '10px' - console.log(TotalCostText) } \ No newline at end of file diff --git a/js/account/avatar-sandbox.html b/js/resources/avatar-sandbox.html similarity index 100% rename from js/account/avatar-sandbox.html rename to js/resources/avatar-sandbox.html diff --git a/js/utils.js b/js/resources/utils.js similarity index 100% rename from js/utils.js rename to js/resources/utils.js diff --git a/js/rewrites/everywhere2.js b/js/rewrites/everywhere2.js deleted file mode 100755 index e101b17..0000000 --- a/js/rewrites/everywhere2.js +++ /dev/null @@ -1,374 +0,0 @@ -const start = performance.now() -var Settings; -var ExpectedSettings = { - 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 -} -var Theme = null; - -// Merge settings and expected settings to make sure all keys exist -let RawSettings = JSON.parse(window.localStorage.getItem('PolyPlusSettings')) || ExpectedSettings -Settings = MergeObjects(RawSettings || ExpectedSettings, ExpectedSettings); -chrome.storage.sync.get(["PolyPlus_Settings"], function(result) { - window.localStorage.setItem('PolyPlusSettings', JSON.stringify(result)) -}); - -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; -} -` - - -document.addEventListener('DOMContentLoaded', function(){ - // 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) - } - } - let end; - if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) { - end = performance.now() - document.body.prepend(Theme) - } - console.log(end - start) - - // Define Data - var Username = document.querySelector('a.text-reset.text-decoration-none[href^="/users"]').innerText.replace(/\s+/g,''); - var UserID = document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2] - var Bricks = document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,''); - - document.body.setAttribute('data-username', Username) - document.body.setAttribute('data-id', UserID) - document.body.setAttribute('data-bricks', Bricks) - document.body.setAttribute('data-URL', window.location.href) - - // Add PolyPlus Settings link to Sidebar - var parent = document.querySelector('ul.nav.nav-flush') - var clone = parent.querySelectorAll('li.nav-item')[0].cloneNode(true) - clone.querySelector('a').setAttribute('href', '/my/settings/polyplus') - clone.querySelector('span').innerText = "Poly+" - var icon = clone.querySelector('i') - var newIcon = document.createElement('i') - newIcon.classList = 'fa-regular fa-sparkles' - icon.parentElement.appendChild(newIcon) - icon.remove() - parent.appendChild(clone) - - 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].setAttribute('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) { - var IRL; - var DISPLAY; - switch (Settings.IRLPriceWithCurrencyCurrency) { - 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 - } - let BrickBalanceCount = document.querySelectorAll('.brickBalanceCount,.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();}); - } -}); - -/* -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 - var Username = document.querySelector('a.text-reset.text-decoration-none[href^="/users"]').innerText.replace(/\s+/g,''); - var UserID = document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2] - var Bricks = document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,''); - - document.body.setAttribute('data-username', Username) - document.body.setAttribute('data-id', UserID) - document.body.setAttribute('data-bricks', Bricks) - document.body.setAttribute('data-URL', window.location.href) - - // Add PolyPlus Settings link to Sidebar - var parent = document.querySelector('ul.nav.nav-flush') - var clone = parent.querySelectorAll('li.nav-item')[0].cloneNode(true) - clone.querySelector('a').setAttribute('href', '/my/polyplus') - clone.querySelector('span').innerText = "Poly+" - var icon = clone.querySelector('i') - var newIcon = document.createElement('i') - newIcon.classList = 'fa-regular fa-sparkles' - icon.parentElement.appendChild(newIcon) - icon.remove() - parent.appendChild(clone) - - 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].setAttribute('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) { - var IRL; - var DISPLAY; - switch (Settings.IRLPriceWithCurrencyCurrency) { - 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 - } - let BrickBalanceCount = document.querySelectorAll('.brickBalanceCount,.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();}); - } -}); -*/ - -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; -} \ No newline at end of file diff --git a/js/rewrites/polyplus-settings.js b/js/rewrites/polyplus-settings.js deleted file mode 100755 index f0057d2..0000000 --- a/js/rewrites/polyplus-settings.js +++ /dev/null @@ -1,883 +0,0 @@ -document.body.innerHTML = ` - - - - - - - - - - - - - -
- <- go back -

Poly+ Settings

-

[CategoryName]

-

- - Pinned Games (enabled) - - -
- Pin your favorite games to the top of the homepage! -

-

- - Forum Mentions (disabled) - - -
- Get a quick link to the popular person everyone is talking about's profile! -

-

- - Best Friends (enabled) - - -
- Prioritize the bestest of friends on applicable friend lists! -

-

- - Improved Friend Lists (enabled) - - -
- - Accept or decline all friend requests with the click of a button or multi-remove existing friends! -
- * You can only remove up to 25 friends at once. -
-

-

- - Show IRL price with Brick Count (enabled) - - -
- - See the real life currency value along with Bricks across the site! -
- * Currencies were calculated on [DATE]. -
- * Currencies other than USD are purely approximations. -
- - - -

-

- - Hide Notification Badges (disabled) - - -
- Hide the annoying red circles on the sidebar! -

-

- - Simplified Profile URLs (enabled) - - -
- Makes all profile URLs simpler by allowing for you to go to "https://polytoria.com/profile/UsernameGoesHere" to redirect to the real profile URL! -

-

- - Show "OWNED" Tag on Store Main Page (enabled) - - -
- 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! -

-

- - Theme Creator (disabled) - - - -
- Unleash your creativity and customize the Polytoria website to your liking! (this feature is still in development) -

-

- - More Search Filters (enabled) - - -
- Easily find what you're looking for with more search filters side-wide! (this does not affect the main site search on the navbar) -

-

- - Apply Membership Theme for Free (disabled) - - -
- Ever want the fancy membership themes for completely free? Well now you can get apply them site-wide! - -

- -

- - Multi-Cancel Outbound Trades (enabled) - - -
- - Quickly cancel several out-bound trades (trades that you have sent) all at once -
- * You can only cancel up to 10 trades at once. -
-

-

- - Modify Navbar (disabled) - - - -
- - Customize the navbar to your liking! - -

-

- - Item Wishlist (enabled) - - -
- - Wishlist that item that you REALLY want! - -

-

- - Hide Upgrade Button (disabled) - - -
- Hide the ugly blue "Upgrade" button on the sidebar! -

-
- - -

made by Index

-
-
-
-
-
-
-
-
-
-
-
-
-
-`; - -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, - BestFriendsOn: true, - ImprovedFrListsOn: true, - IRLPriceWithCurrencyOn: true, - IRLPriceWithCurrencyCurrency: 0, - IRLPriceWithCurrencyPackage: 0, - HideNotifBadgesOn: false, - 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, - MultiCancelOutTradesOn: true, - ItemWishlistOn: true, - HideUpgradeBtnOn: false -} - -var ResetDefaultsModal = document.getElementById('ResetDefaults-Modal') -var ThemeCreatorModal = { - Modal: document.getElementById('ThemeCreator-Modal'), - Save: document.getElementById('ThemeCreator-Modal-Save'), - BGColor: document.getElementById('ThemeCreator-Modal-BGColor'), - BGImage: document.getElementById('ThemeCreator-Modal-BGImage'), - BGImageSize: document.getElementById('ThemeCreator-Modal-BGImageSize'), - PrimaryTextColor: document.getElementById('ThemeCreator-Modal-PrimaryTextColor'), - SecondaryTextColor: document.getElementById('ThemeCreator-Modal-SecondaryTextColor'), - LinkTextColor: document.getElementById('ThemeCreator-Modal-LinkTextColor'), - WebsiteLogo: document.getElementById('ThemeCreator-Modal-WebsiteLogo') -} -var ModifyNavModal = { - Modal: document.getElementById('ModifyNav-Modal'), - Save: document.getElementById('ModifyNav-Modal-Save'), - "1Label": document.getElementById('ModifyNav-Modal-1Label'), - "1Link": document.getElementById('ModifyNav-Modal-1Link'), - "2Label": document.getElementById('ModifyNav-Modal-2Label'), - "2Link": document.getElementById('ModifyNav-Modal-2Link'), - "3Label": document.getElementById('ModifyNav-Modal-3Label'), - "3Link": document.getElementById('ModifyNav-Modal-3Link'), - "4Label": document.getElementById('ModifyNav-Modal-4Label'), - "4Link": document.getElementById('ModifyNav-Modal-4Link'), - "5Label": document.getElementById('ModifyNav-Modal-5Label'), - "5Link": document.getElementById('ModifyNav-Modal-5Link'), -} -SaveBtn.addEventListener("click", function() { - Save(); -}); -Elements.forEach(element => { - let Button = element.getElementsByTagName('button')[0] - let Options = element.getElementsByTagName('button')[1] - let Select = element.getElementsByTagName('select') || [] - - if (Button) { - Button.addEventListener('click', function() { - console.log('button clicked!!!!') - ToggleSetting(Button.getAttribute('data-setting'), element) - }); - } - - if (Options) { - Options.addEventListener('click', function() { - let Modal = document.getElementById(Options.getAttribute('data-modal') + '-Modal') - let ModalButtons = Modal.getElementsByTagName('button') - let ModalInputs = Modal.getElementsByTagName('input') - let ModalSelect = Modal.getElementsByTagName('select') - - Array.from(ModalButtons).forEach(btn => { - if (!(btn.getAttribute('data-ignore') === 'true')) { - btn.addEventListener('click', function(){ - let Setting = btn.getAttribute('data-setting') - if (Setting === '[save]') { - Array.from(ModalInputs).forEach(input => { - if (!(input.getAttribute('data-ignore') === 'true')) { - if (!(input.getAttribute('data-parent'))) { - Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] = input.value || null - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - Settings[Modal.getAttribute('data-setting')][Parent][input.getAttribute('data-setting')] = input.value || null - } - } - }); - Array.from(ModalSelect).forEach(select => { - if (!(select.getAttribute('data-ignore') === 'true')) { - if (!(select.getAttribute('data-parent'))) { - Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] = select.selectedIndex - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] = select.selectedIndex - } - } - }); - Save(); - setTimeout(function () { - LoadCurrent(); - Modal.close(); - }, 400) - } else if (Setting === '[cancel]') { - Modal.close(); - } else if (Setting === '[callback]') { - let Function = btn.getAttribute('data-onclick') - if (window[Function] && typeof(window[Function]) === 'function') { - console.log('is') - window[Function]() - } - } else { - if (!(btn.getAttribute('data-parent'))) { - ToggleSetting(Modal.getAttribute('data-setting')[btn.getAttribute('data-setting')], null) - } else { - let Parent = input.getAttribute('data-parent') - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - ToggleSetting(Modal.getAttribute('data-setting')[Parent][btn.getAttribute('data-setting')], null) - } - } - }); - } - }); - - 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") { - input.value = Settings[Modal.getAttribute('data-setting')][input.getAttribute('data-setting')] - } - } else { - let Parent = input.getAttribute('data-parent') - if (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')] - } - } - } - }); - - Array.from(ModalSelect).forEach(select => { - if (!(select.getAttribute('data-ignore') === 'true')) { - if (!(select.getAttribute('data-parent'))) { - if (Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] !== "undefined") { - select.selectedIndex = Settings[Modal.getAttribute('data-setting')][select.getAttribute('data-setting')] - } - } else { - let Parent = input.getAttribute('data-parent') - if (Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] !== "undefined") { - if (!isNaN(parseInt(Parent))) {Parent = parseInt(Parent)} - select.selectedIndex = Settings[Modal.getAttribute('data-setting')][Parent][select.getAttribute('data-setting')] - } - } - } - }); - - Modal.showModal() - }); - } - - if (Select.length > 0) { - Array.from(Select).forEach(element => { - element.addEventListener('change', function() { - SetSetting(element.getAttribute('data-setting'), element, element.selectedIndex) - }); - }); - } -}); -document.getElementById('ResetDefaults').addEventListener('click', function() { - ResetDefaultsModal.showModal(); -}); -document.getElementById('ResetDefaults-Modal-Yes').addEventListener('click', function() { - Settings = ExpectedSettings - Save() - setTimeout(function () { - LoadCurrent(); - ResetDefaultsModal.close(); - }, 400) -}); -document.getElementById('ResetDefaults-Modal-No').addEventListener('click', function() { - ResetDefaultsModal.close(); -}); - -function LoadCurrent() { - chrome.storage.sync.get(["PolyPlus_Settings"], function(result) { - Settings = MergeObjects(result.PolyPlus_Settings || ExpectedSettings, ExpectedSettings) - - console.log(Settings) - - Elements.forEach(element => { - let Status = element.getElementsByClassName('status')[0] - console.log(element, FormatBool(Settings[element.getElementsByTagName('button')[0].getAttribute('data-setting')])) - Status.innerText = FormatBool(Settings[element.getElementsByTagName('button')[0].getAttribute('data-setting')]) - let SelectInput = element.getElementsByTagName('select')[0] - if (SelectInput) { - SelectInput.selectedIndex = Settings[SelectInput.getAttribute('data-setting')] - } - }); - }); -} -LoadCurrent(); - -function ToggleSetting(Name, Element) { - if (Settings[Name] === true) { - Settings[Name] = false; - } else { - Settings[Name] = true; - } - - if (Element != null) { - Element.getElementsByClassName('status')[0].innerText = FormatBool(Settings[Name]) - } - if (SaveBtn.getAttribute('disabled')) { - SaveBtn.removeAttribute('disabled') - } -} - -function SetSetting(Name, Element, Value) { - console.log(Settings) - Settings[Name] = Value - - if (SaveBtn.getAttribute('disabled')) { - SaveBtn.removeAttribute('disabled') - } -} - -function Save() { - SaveBtn.setAttribute('disabled', 'true') - chrome.storage.sync.set({ 'PolyPlus_Settings': Settings, arrayOrder: true }, function() { - console.log('Saved successfully!'); - }); - - console.log(Settings); -} - -let LoadThemeFromJSONBtn = document.getElementById('LoadThemeFromJSONBtn') -let SaveThemeToJSONInput = document.getElementById('SaveThemeToJSONInput') -let CopyThemeJSONBtn = document.getElementById('CopyThemeJSONBtn') -LoadThemeFromJSONBtn.addEventListener('click', function(){ - LoadThemeJSON(LoadThemeFromJSONBtn.previousElementSibling.value) -}); -document.getElementById('ThemeCreator').getElementsByTagName('button')[1].addEventListener('click', function(){ - SaveThemeToJSONInput.value = JSON.stringify(Settings.ThemeCreator) -}); -CopyThemeJSONBtn.addEventListener('click', function(){ - if (SaveThemeToJSONInput.value.length > 0) { - navigator.clipboard.writeText(SaveThemeToJSONInput.value) - } -}); - -let CurrencyDate = -LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){ - CurrencyDate = new Date(JSON.parse(text).Date).toLocaleDateString("en-US", {day:"numeric",month:"long",year:"numeric"}) - - document.getElementById('IRLPriceWithCurrencyCurrency').previousElementSibling.children[1].innerText = document.getElementById('IRLPriceWithCurrencyCurrency').previousElementSibling.children[1].innerText.replace('[DATE]', CurrencyDate) -}) - -function LoadThemeJSON(string) { - 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() - Settings.ThemeCreator = MergeObjects(JSONTable, ExpectedSettings.ThemeCreator) - Save(); - console.log(JSONTable.length, JSONTable, 'applied') - document.getElementById('ThemeCreator').getElementsByTagName('button')[1].click(); - } - } else { - alert('JSON is not a theme!') - //LoadThemeFromJSONBtn.innerText = 'JSON is too short or too long!' - //setTimeout(function () {LoadThemeFromJSONBtn.innerText = 'Load'}, 1250) - } - } catch (error) { - alert('JSON is invalid!') - //LoadThemeFromJSONBtn.innerText = 'JSON is invalid!' - //setTimeout(function () {LoadThemeFromJSONBtn.innerText = 'Load'}, 1250) - } -} - -/* -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]; - } else if (obj1[key] !== obj2[key]) { - mergedObj[key] = obj2[key]; - } - } - - // Remove keys from mergedObj if they are not present in obj2 - for (var key in mergedObj) { - if (!obj2.hasOwnProperty(key)) { - delete mergedObj[key]; - } - } - - return mergedObj; -} -*/ - -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; -} - -function FormatBool(bool){ - if (bool === true) { - return 'enabled' - } else { - return 'disabled' - } -} - -function LoadFile(path, callback) { - var xhr = new XMLHttpRequest(); - xhr.onload = function () { return callback(this.responseText); } - xhr.open("GET", path, true); - xhr.send(); -} \ No newline at end of file diff --git a/js/store/item-view.js b/js/store/item-view.js index 1da702f..37c1885 100755 --- a/js/store/item-view.js +++ b/js/store/item-view.js @@ -1,139 +1,148 @@ -var ItemID = window.location.pathname.split('/')[2] +const ItemID = window.location.pathname.split('/')[2] + var ItemWishlist; +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; - let PurchaseBtn = document.querySelector('.btn.btn-outline-success') - if (Settings.IRLPriceWithCurrencyOn === true){ - if (!(PurchaseBtn.getAttribute('disabled'))) { - let Price = PurchaseBtn.getAttribute('data-price').replace(/,/g, '') - let 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 + ")" - PurchaseBtn.appendChild(Span) - } + var Settings = result.PolyPlus_Settings || { + IRLPriceWithCurrencyOn: false, + IRLPriceWithCurrencyCurrency: 0, + ItemWishlistOn: true } + PurchaseBtn = document.getElementsByClassName('btn btn-outline-success')[0] + + if (Settings.IRLPriceWithCurrencyOn === true){ IRLPrice() } if (Settings.ItemWishlistOn === true && !(PurchaseBtn.getAttribute('disabled'))) { - let DescriptionText = document.querySelector('.card-text') - WishlistBtn = document.createElement('button') - chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){ - ItemWishlist = result.PolyPlus_ItemWishlist || []; - - if (Array.isArray(ItemWishlist) && ItemWishlist.includes(parseInt(ItemID))) { - WishlistBtn.classList = 'btn btn-danger btn-sm' - WishlistBtn.innerHTML = ` - Un-Wishlist Item - ` - } else { - WishlistBtn.classList = 'btn btn-primary btn-sm' - WishlistBtn.innerHTML = ` - Wishlist Item - ` - } - - WishlistBtn.addEventListener('click', function(){ - Wishlist() - }); - - DescriptionText.appendChild(document.createElement('br')) - DescriptionText.appendChild(WishlistBtn) - - function Wishlist() { - WishlistBtn.setAttribute('disabled', true) - chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){ - ItemWishlist = result.PolyPlus_ItemWishlist || []; - - let i = ItemWishlist.indexOf(parseInt(ItemID)) - console.log(i) - if (i !== -1) { - ItemWishlist.splice(i, 1) - WishlistBtn.classList = 'btn btn-primary btn-sm' - WishlistBtn.innerHTML = ` - Wishlist Item - ` - } else { - ItemWishlist.push(parseInt(ItemID)) - WishlistBtn.classList = 'btn btn-danger btn-sm' - WishlistBtn.innerHTML = ` - Un-Wishlist Item - ` - } - - chrome.storage.sync.set({'PolyPlus_ItemWishlist': ItemWishlist, arrayOrder: true}, function() { - setTimeout(function() { - WishlistBtn.removeAttribute('disabled') - }, 1250) - }); - }); - } - }); + HandleItemWishlist() } }) }, 100) chrome.storage.onChanged.addListener(function(changes, namespace) { if ('PolyPlus_ItemWishlist' in changes) { - chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result) { - ItemWishlist = result.PolyPlus_ItemWishlist || []; + chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result) { + ItemWishlist = result.PolyPlus_ItemWishlist || []; - if (Array.isArray(ItemWishlist) && ItemWishlist.includes(parseInt(ItemID))) { - WishlistBtn.classList = 'btn btn-danger btn-sm' - WishlistBtn.innerHTML = ` - Un-Wishlist Item - ` - } else { - if (!(ItemWishlist.length === 25)) { - WishlistBtn.removeAttribute('disabled') - WishlistBtn.classList = 'btn btn-primary btn-sm' - WishlistBtn.innerHTML = ` - Wishlist Item - ` - } else { - WishlistBtn.setAttribute('disabled', true) - WishlistBtn.classList = 'btn btn-primary btn-sm' - WishlistBtn.innerHTML = ` - Wishlist Item - ` - } - } - }); + if (Array.isArray(ItemWishlist) && ItemWishlist.includes(parseInt(ItemID))) { + WishlistBtn.classList = 'btn btn-danger btn-sm' + WishlistBtn.innerHTML = ` + Un-Wishlist Item + ` + } else { + if (!(ItemWishlist.length === 25)) { + WishlistBtn.removeAttribute('disabled') + WishlistBtn.classList = 'btn btn-primary btn-sm' + WishlistBtn.innerHTML = ` + Wishlist Item + ` + } else { + WishlistBtn.setAttribute('disabled', true) + WishlistBtn.classList = 'btn btn-primary btn-sm' + WishlistBtn.innerHTML = ` + Wishlist Item + ` + } + } + }); } -}); \ No newline at end of file +}); + +function IRLPrice() { + if (!(PurchaseBtn.getAttribute('disabled'))) { + let Price = PurchaseBtn.getAttribute('data-price').replace(/,/g, '') + let 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 + ")" + PurchaseBtn.appendChild(Span) + } +} + +function HandleItemWishlist() { + const DescriptionText = document.getElementsByClassName('card-text')[0] + WishlistBtn = document.createElement('button') + chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){ + ItemWishlist = result.PolyPlus_ItemWishlist || []; + + if (Array.isArray(ItemWishlist) && ItemWishlist.includes(parseInt(ItemID))) { + WishlistBtn.classList = 'btn btn-danger btn-sm' + WishlistBtn.innerHTML = ` + Un-Wishlist Item + ` + } else { + WishlistBtn.classList = 'btn btn-primary btn-sm' + WishlistBtn.innerHTML = ` + Wishlist Item + ` + } + + WishlistBtn.addEventListener('click', function(){ + WishlistBtn.setAttribute('disabled', true) + chrome.storage.sync.get(['PolyPlus_ItemWishlist'], function(result){ + ItemWishlist = result.PolyPlus_ItemWishlist || []; + + let i = ItemWishlist.indexOf(parseInt(ItemID)) + console.log(i) + if (i !== -1) { + ItemWishlist.splice(i, 1) + WishlistBtn.classList = 'btn btn-primary btn-sm' + WishlistBtn.innerHTML = ` + Wishlist Item + ` + } else { + ItemWishlist.push(parseInt(ItemID)) + WishlistBtn.classList = 'btn btn-danger btn-sm' + WishlistBtn.innerHTML = ` + Un-Wishlist Item + ` + } + + chrome.storage.sync.set({'PolyPlus_ItemWishlist': ItemWishlist, arrayOrder: true}, function() { + setTimeout(function() { + WishlistBtn.removeAttribute('disabled') + }, 1250) + }); + }); + }); + + DescriptionText.appendChild(document.createElement('br')) + DescriptionText.appendChild(WishlistBtn) + }); +} \ No newline at end of file diff --git a/js/trick-or-treat.js b/js/trick-or-treat.js deleted file mode 100755 index 9d6620e..0000000 --- a/js/trick-or-treat.js +++ /dev/null @@ -1,13 +0,0 @@ -// This was for the limited time 2023 halloween event -const HauntedStudsCount = document.querySelector('[href="/event/active"] .brickBalanceCount') -if (HauntedStudsCount !== null) { - HauntedStudsCount.innerHTML = HauntedStudsCount.innerHTML + ` (${parseInt(HauntedStudsCount.innerText) / 8} candies)` -} - -if (window.location.pathname === '/event/trick-o-toria-2023') { - const LeaderboardRows = document.getElementsByClassName('leaderboard-row') - Array.from(LeaderboardRows).forEach(row => { - const _HauntedStudsCount = row.querySelector('span[style^="color:#cd60ff;"]') - _HauntedStudsCount.innerHTML = _HauntedStudsCount.innerHTML + `
(${parseFloat(_HauntedStudsCount.innerText.replace(/,/g, '')) / 8} candies)` - }); -} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 0f9065f..f225ca9 100755 --- a/manifest.json +++ b/manifest.json @@ -32,7 +32,7 @@ { "matches": ["https://polytoria.com/places/**"], - "js": ["/js/places/place-view.js"] + "js": ["/js/places/place-view2.js"] }, { @@ -126,17 +126,7 @@ ], "web_accessible_resources": [ { - "resources": ["js/resources/currencies.json", "settings.html", "settings.js"], - "matches": ["https://polytoria.com/*"] - }, - - { - "resources": ["js/utils.js"], - "matches": ["https://polytoria.com/*"] - }, - - { - "resources": ["js/account/avatar-sandbox.html"], + "resources": ["js/resources/*"], "matches": ["https://polytoria.com/*"] } ], diff --git a/settings.html b/settings.html index bebb345..00a99f4 100755 --- a/settings.html +++ b/settings.html @@ -1,7 +1,7 @@ Poly+ Settings - +