diff --git a/README.md b/README.md index 75c61ed..b822ff6 100644 --- a/README.md +++ b/README.md @@ -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! @@ -10,4 +10,4 @@ As of right now, Poly+ only works on chromium-based browsers and Firefox (howeve 1. First enable developer mode on your browser (developer mode allows you to load unpacked extensions) 2. Second click the "Load Unpacked" button 3. Third when the file selector comes up pick the unzipped folder from this GitHub repository -4. Fourth go to Polytoria and you should see the extension's button on the sidebar +4. Fourth go to Polytoria and you should see the extension's button on the sidebar \ No newline at end of file diff --git a/js/account/home.js b/js/account/home.js index 558df4e..741d927 100755 --- a/js/account/home.js +++ b/js/account/home.js @@ -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) { diff --git a/js/background.js b/js/background.js index 44cccfc..6424e6c 100755 --- a/js/background.js +++ b/js/background.js @@ -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 @@ -121,30 +115,4 @@ function CopyAvatarHash(hash) { .catch(() => { 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 } \ No newline at end of file diff --git a/js/everywhere.js b/js/everywhere.js index 832197a..e6e7665 100755 --- a/js/everywhere.js +++ b/js/everywhere.js @@ -8,7 +8,6 @@ const ExpectedSettings = { IRLPriceWithCurrencyCurrency: 0, IRLPriceWithCurrencyPackage: 0, HideNotifBadgesOn: true, - SimplifiedProfileURLsOn: true, StoreOwnTagOn: true, ThemeCreatorOn: false, ThemeCreator: { diff --git a/js/places/place-view2.js b/js/places/place-view2.js index b51adfe..e7e3a24 100644 --- a/js/places/place-view2.js +++ b/js/places/place-view2.js @@ -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 = ' 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 = ' 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] + PinnedGames = result.PolyPlus_PinnedGames || []; + /* + const Index = PinnedGames.indexOf(parseInt(GameID)) + if (Index !== -1) { + //delete PinnedGames[GameID] + PinnedGames.splice(Index, 1) PinBtn.innerHTML = ' Pin' } else { - PinnedGames[GameID] = {lastVisited: new Date()} + //PinnedGames[GameID] = {lastVisited: new Date()} + PinnedGames.push(parseInt(GameID)) + PinBtn.innerHTML = ' Un-pin' + } + */ + const Index = PinnedGames.indexOf(parseInt(GameID)); + if (Index !== -1) { + PinnedGames.splice(Index, 1); + PinBtn.innerHTML = ' Pin' + } else { + PinnedGames.push(parseInt(GameID)); PinBtn.innerHTML = ' 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 = ' Un-pin' } else { @@ -101,6 +136,18 @@ async function HandlePinnedGames() { PinBtn.innerHTML = ' Pin (max 5/5)' } } + */ + if (PinnedGames.includes(parseInt(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)' + } + } }); } }); diff --git a/js/store/item-view.js b/js/store/item-view.js index 37c1885..a8bdb9c 100755 --- a/js/store/item-view.js +++ b/js/store/item-view.js @@ -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 || []; diff --git a/manifest.json b/manifest.json index f225ca9..81ece9c 100755 --- a/manifest.json +++ b/manifest.json @@ -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"] }, { diff --git a/Generate-UnitPrices.js b/old.js similarity index 100% rename from Generate-UnitPrices.js rename to old.js diff --git a/settings.html b/settings.html index 00a99f4..fb9d69e 100755 --- a/settings.html +++ b/settings.html @@ -1,6 +1,13 @@ - Poly+ Settings + + + + + + Poly+ | Settings + + @@ -328,7 +335,7 @@
-

+

Pinned Games (enabled) @@ -336,7 +343,7 @@
Pin your favorite games to the top of the homepage!

-

+

Forum Mentions (disabled) @@ -344,7 +351,7 @@
Get a quick link to the popular person everyone is talking about's profile!

-

+

Best Friends (enabled) @@ -352,7 +359,7 @@
Prioritize the bestest of friends on applicable friend lists!

-

+

Improved Friend Lists (enabled) @@ -364,7 +371,7 @@ * You can only remove up to 25 friends at once.

-

+

Show IRL price with Brick Count (enabled) @@ -396,7 +403,7 @@

-

+

Hide Notification Badges (disabled) @@ -404,7 +411,10 @@
Hide the annoying red circles on the sidebar!

-

+ +

Show "OWNED" Tag on Store Main Page (enabled) @@ -420,7 +431,7 @@
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) @@ -429,7 +440,7 @@
Unleash your creativity and customize the Polytoria website to your liking! (this feature is still in development)

-

+

More Search Filters (enabled) @@ -437,7 +448,7 @@
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) @@ -449,7 +460,10 @@

-

Multi-Cancel Outbound Trades (enabled) @@ -471,7 +486,7 @@ * You can only cancel up to 10 trades at once.

-

+

Modify Navbar (disabled) @@ -482,7 +497,7 @@ Customize the navbar to your liking!

-

+

Item Wishlist (enabled) @@ -492,7 +507,7 @@ Wishlist that item that you REALLY want!

-

+

Hide Upgrade Button (disabled) diff --git a/settings.js b/settings.js index 588bb50..8f88dc8 100755 --- a/settings.js +++ b/settings.js @@ -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 = '' } } }