diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/css/specific.css b/css/specific.css index c47950e..04c7eca 100755 --- a/css/specific.css +++ b/css/specific.css @@ -1,12 +1,12 @@ -body[data-URL^="https://polytoria.com/my/friends"] .col-lg-3 { +body[data-URL^="/my/friends"] .col-lg-3 { margin-bottom: 20px; } -body[data-URL^="https://polytoria.com/create/"] .mt-2.mt-lg-0.col-lg.d-flex.align-content-between.flex-wrap { +body[data-URL^="/create/"] .mt-2.mt-lg-0.col-lg.d-flex.align-content-between.flex-wrap { width: 50%; } -body[data-URL^="https://polytoria.com/create/"] .col.d-flex.align-content-between.flex-wrap { +body[data-URL^="/create/"] .col.d-flex.align-content-between.flex-wrap { width: 50%; } diff --git a/data_structure.txt b/data_structure.txt index 9a6abb9..fd5eac3 100755 --- a/data_structure.txt +++ b/data_structure.txt @@ -1,4 +1,4 @@ -PolyPlus_Settings: [] +PolyPlus_Settings: {} PolyPlus_PinnedGames: [] PolyPlus_BestFriends: [] PolyPlus_ItemWishlist: [] \ No newline at end of file diff --git a/js/everywhere.js b/js/everywhere.js index 613ca6e..9ab5a5d 100755 --- a/js/everywhere.js +++ b/js/everywhere.js @@ -137,7 +137,7 @@ let Theme = null; } window.localStorage.setItem('account_info', JSON.stringify(UserData)) - document.body.setAttribute('data-URL', window.location.href) + document.body.setAttribute('data-URL', window.location.pathname) // Add PolyPlus Settings link to Sidebar const Parent = document.querySelector('ul.nav.nav-flush') diff --git a/js/places/places.js b/js/places/places.js new file mode 100644 index 0000000..01717ec --- /dev/null +++ b/js/places/places.js @@ -0,0 +1,25 @@ +let Settings; +let PinnedGamesData; + +chrome.storage.sync.get(['PolyPlus_Settings', 'PolyPlus_PinnedGames'], function(result){ + Settings = result.PolyPlus_Settings || {} + PinnedGamesData = result.PolyPlus_PinnedGames || [] + + if (Settings.PinnedGamesOn === true) {} +}) + +function PinnedGames() { + for (let game of PinnedGamesData) { + fetch('https://api.polytoria.com/v1/places/' + game) + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.json() + }) + .then(data => { + // epic + }) + .catch(error => {console.log(error)}) + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 29abffa..2a14022 100755 --- a/manifest.json +++ b/manifest.json @@ -2,6 +2,7 @@ "manifest_version": 3, "name": "Poly+", "version": "1.11", + "version_name": "Pre-Release Build (stable: v1.1.1)", "description": "Power-up your Polytoria experience with Poly+! Created by Index.", "permissions": ["storage", "contextMenus", "tabs", "scripting", "alarms", "notifications"], "content_scripts": [ diff --git a/settings.html b/settings.html index 7e973ab..2ae1011 100755 --- a/settings.html +++ b/settings.html @@ -4,10 +4,10 @@ - - Poly+ | Settings + + Poly+ Settings - + @@ -48,7 +48,7 @@ margin-right: 15px; } - p span:first-child { + p span.title { font-size: 1.4rem; } @@ -91,37 +91,32 @@ dialog .modal-body p:first-child { font-size: 0.9rem; } + + .setting-container .indicator { + border-radius: 5rem; + display: inline-block; + cursor: default; + } - /* - p span span.status { - font-size: 0.16rem !important; - color: #cee; - } - */ - - /* - button { - border: none; - padding: 5px; - color: #fff; - border-radius: 5px; + .setting-container.enabled .indicator { + background-color: #007bff; } - button.btn-primary { - background: #007bff; + .setting-container.disabled .indicator { + background-color: orangered; } - button.btn-warning { - background: orange; + .toggle-btn { + float: right; + width: 100px; } - */ @@ -131,22 +126,20 @@

Theme Creator

@@ -323,18 +313,21 @@
-

- - Pinned Games (enabled) - +

Poly+ Settings

+

+   + + Pinned Games +
Pin your favorite places to the top of the homepage! (limit: 5 places)

- - Forum Mentions (disabled) - +   + + Forum Mentions +
Get a quick link to the popular person everyone is talking about's profile! @@ -342,17 +335,19 @@ * Forum Mentions do not notify the user.

- - Best Friends (enabled) - +   + + Best Friends +
Prioritize the bestest of friends on applicable friend lists! (limit: 7 best friends)

- - Improved Friend Lists (enabled) - +   + + Improved Friend Lists +
@@ -362,9 +357,10 @@

- - Show IRL price with Brick Count (enabled) - +   + + Show IRL price with Brick Count +
@@ -396,42 +392,47 @@ -->

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

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

- - More Search Filters (enabled) - +   + + More Search Filters +
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) - +   + + Apply Membership Theme for Free +
Ever want the fancy membership themes for completely free? Well now you can get apply them site-wide! @@ -441,9 +442,10 @@

- - Multi-Cancel Outbound Trades (enabled) - +   + + Multi-Cancel Outbound Trades +
@@ -453,9 +455,10 @@

- - Modify Navbar (disabled) - +   + + Modify Navbar +
@@ -464,9 +467,10 @@

- - Item Wishlist (enabled) - +   + + Item Wishlist +
@@ -474,17 +478,19 @@

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

- - Show Outfit Cost on Profiles (enabled) - +   + + Show Outfit Cost on Profiles +
Quickly see how many bricks a user spent on their avatar! @@ -496,9 +502,10 @@


- - Inline Editing (disabled) - +   + + Inline Editing +
Quickly edit your asset's details such as name and description on the same page as viewing the asset! @@ -521,9 +529,10 @@ * This feature is not finished or polished.

- - Forum Unix Timestamps (disabled) - +   + + Forum Unix Timestamps +
See a date and time that is adjusted to everyone (who is using Poly+)'s local time @@ -533,9 +542,11 @@


- - -

made by Index

+
+ + +
+

made by Index

diff --git a/settings.js b/settings.js index f9ff588..7b820e8 100755 --- a/settings.js +++ b/settings.js @@ -2,59 +2,8 @@ const SaveBtn = document.getElementById('Save') const Elements = Array.from(document.getElementsByClassName('setting-container')) var Settings; -/* -var ExpectedSettings = { - PinnedGamesOn: true, - ForumMentsOn: false, - BestFriendsOn: true, - ImprovedFrListsOn: true, - IRLPriceWithCurrencyOn: true, - IRLPriceWithCurrencyCurrency: 0, - IRLPriceWithCurrencyPackage: 0, - HideNotifBadgesOn: false, - StoreOwnTagOn: true, - ThemeCreatorOn: false, - ThemeCreator: { - BGColor: null, - BGImage: null, - BGImageSize: 'fit', - PrimaryTextColor: null, - SecondaryTextColor: null, - LinkTextColor: null, - WebsiteLogo: null - }, - ModifyNavOn: false, - ModifyNav: [ - { - Label: "Places", - Link: "https://polytoria.com/places" - }, - { - Label: "Store", - Link: "https://polytoria.com/store" - }, - { - Label: "Guilds", - Link: "https://polytoria.com/guilds" - }, - { - Label: "People", - Link: "https://polytoria.com/users" - }, - { - Label: "Forum", - Link: "https://polytoria.com/forum" - } - ], - MoreSearchFiltersOn: true, - ApplyMembershipThemeOn: false, - ApplyMembershipThemeTheme: 0, - MultiCancelOutTradesOn: true, - ItemWishlistOn: true, - HideUpgradeBtnOn: false -} -*/ var ExpectedSettings; + var Utilities; (async () => { Utilities = await import(chrome.runtime.getURL('/js/resources/utils.js')); @@ -65,40 +14,42 @@ var Utilities; LoadCurrent() })(); -const 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'), -} +// Handle buttons at the bottom of the page +document.getElementById('ResetDefaults').addEventListener('click', function() { + document.getElementById('ResetDefaults-Modal').showModal(); +}); SaveBtn.addEventListener("click", function() { Save(); }); + +// Handle modal buttons for Reset Defaults modal +document.getElementById('ResetDefaults-Modal-Yes').addEventListener('click', function() { + Settings = ExpectedSettings + Save() + setTimeout(function () { + LoadCurrent(); + document.getElementById('ResetDefaults-Modal').close(); + }, 400) +}); +document.getElementById('ResetDefaults-Modal-No').addEventListener('click', function() { + document.getElementById('ResetDefaults-Modal').close(); +}); + +// Handle leaving the settings page before saving +/* +window.onbeforeunload = function() { + if (SaveBtn.getAttribute('disabled') !== null) { + return "Are you sure you'd like to leave? Your Poly+ settings haven't been saved." + } + return "aaa" +} +*/ + +// Loop thru each setting container and handle toggling, selecting, opening modal, etc Elements.forEach(element => { let Button = element.getElementsByTagName('button')[0] let Options = element.getElementsByTagName('button')[1] let Select = element.getElementsByTagName('select') || [] - console.log(element, Select) if (Button) { Button.addEventListener('click', function() { @@ -208,32 +159,33 @@ Elements.forEach(element => { }); } }); -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) + console.log("Current:", Settings) Elements.forEach(element => { + /* let Status = element.getElementsByClassName('status')[0] if (Status !== undefined) { Status.innerText = FormatBool(Settings[element.getElementsByTagName('button')[0].getAttribute('data-setting')]) } + */ + console.log(Settings) + const ToggleBtn = element.getElementsByClassName('toggle-btn')[0] + if (Settings[ToggleBtn.getAttribute('data-setting')] === true) { + console.log(ToggleBtn.parentElement, 'enabled', Settings[ToggleBtn.getAttribute('data-setting')]) + element.classList.add('enabled') + ToggleBtn.innerText = 'Disable' + ToggleBtn.classList.add('btn-danger') + } else { + console.log(ToggleBtn.parentElement, 'disabled', Settings[ToggleBtn.getAttribute('data-setting')]) + element.classList.add('disabled') + ToggleBtn.innerText = 'Enable' + ToggleBtn.classList.add('btn-success') + } let SelectInput = element.getElementsByTagName('select')[0] if (SelectInput) { SelectInput.selectedIndex = Settings[SelectInput.getAttribute('data-setting')] @@ -243,17 +195,21 @@ function LoadCurrent() { } function ToggleSetting(Name, Element) { + const ToggleBtn = Element.getElementsByClassName('toggle-btn')[0] + document.title = "*unsaved | Poly+ Settings" if (Settings[Name] === true) { Settings[Name] = false; + ToggleBtn.innerText = 'Enable' } else { Settings[Name] = true; + ToggleBtn.innerText = 'Disable' } + Element.classList.toggle('enabled') + Element.classList.toggle('disabled') + ToggleBtn.classList.toggle('btn-success') + ToggleBtn.classList.toggle('btn-danger') - if (Element != null) { - Element.getElementsByClassName('status')[0].innerText = FormatBool(Settings[Name]) - } if (SaveBtn.getAttribute('disabled')) { - console.log('is disabled button - toggle') SaveBtn.removeAttribute('disabled') } } @@ -263,18 +219,18 @@ function SetSetting(Name, Element, Value) { Settings[Name] = Value if (SaveBtn.getAttribute('disabled')) { - console.log('is disabled button') SaveBtn.removeAttribute('disabled') } } function Save() { + document.title = 'Poly+ Settings' SaveBtn.setAttribute('disabled', 'true') chrome.storage.sync.set({ 'PolyPlus_Settings': Settings, arrayOrder: true }, function() { console.log('Saved successfully!'); }); - console.log(Settings); + console.log("Save:", Settings); } let LoadThemeFromJSONBtn = document.getElementById('LoadThemeFromJSONBtn') @@ -306,19 +262,17 @@ LoadFile(chrome.runtime.getURL('js/resources/currencies.json'), function(text){ }) function LoadThemeJSON(string) { - alert('This feature has been disabled for now.') - return 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() - /* for (let i = 0; i < JSONTable.length; i++) { - JSONTable[i] = new Sanitzer(JSONTable[i]) + if (JSONTable[i][0] !== "#") { + JSONTable[i] = "" + } } - */ Settings.ThemeCreator = MergeObjects(JSONTable, ExpectedSettings.ThemeCreator) Save(); console.log(JSONTable.length, JSONTable, 'applied') @@ -326,45 +280,13 @@ function LoadThemeJSON(string) { } } 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; -} -*/ - +// MergeObjects function was written by ChatGPT cause I was lazy and it was awhile ago function MergeObjects(obj1, obj2) { var mergedObj = {}; @@ -384,11 +306,8 @@ function MergeObjects(obj1, obj2) { } function FormatBool(bool){ - if (bool === true) { - return 'enabled' - } else { - return 'disabled' - } + if (bool === true) { return 'enabled' } + else { return 'disabled' } } function LoadFile(path, callback) {