diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml
deleted file mode 100644
index 98772d8..0000000
--- a/.github/workflows/prettier.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-name: Prettier Format and Commit
-
-on:
- push:
- branches:
- - main
- - 'refs/heads/*'
-
-jobs:
- prettier:
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- node-version: 'latest'
-
- - name: Install dependencies
- run: npm install
-
- - name: Pull latest changes
- run: git pull
-
- - name: Run Prettier
- run: npx prettier --write .
-
- - name: Commit changes
- id: commit
- run: |
- git config --global user.name "github-actions[bot]"
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
- git add .
- if git diff-index --quiet HEAD; then
- echo "No changes to commit."
- echo "changes_committed=false" >> $GITHUB_ENV
- else
- git commit -m "chore: format code with Prettier"
- echo "changes_committed=true" >> $GITHUB_ENV
- fi
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Push changes
- if: env.changes_committed == 'true'
- run: git push
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 7c91ab4..496ee2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
-.DS_Store
-/node_modules/
\ No newline at end of file
+.DS_Store
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
deleted file mode 100644
index fa4cde3..0000000
--- a/.prettierrc
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "arrowParens": "always",
- "bracketSpacing": false,
- "printWidth": 200,
- "singleQuote": true,
- "trailingComma": "none",
- "useTabs": true,
- "plugins": ["prettier-plugin-jinja-template"],
- "overrides": [
- {
- "files": "*.html",
- "options": {
- "parser": "jinja-template"
- }
- }
- ]
-}
diff --git a/js/account/home.js b/js/account/home.js
index 9730367..7cc4776 100755
--- a/js/account/home.js
+++ b/js/account/home.js
@@ -11,7 +11,7 @@ let Utilities;
chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) {
Settings = result.PolyPlus_Settings || Utilities.DefaultSettings;
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice();
}
diff --git a/js/account/profile.js b/js/account/profile.js
index 64c935d..95b40fa 100755
--- a/js/account/profile.js
+++ b/js/account/profile.js
@@ -18,7 +18,7 @@ if (UserID) {
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
Settings = result.PolyPlus_Settings || {};
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice();
}
diff --git a/js/guilds.js b/js/guilds.js
index 02faf1f..1dee9a8 100644
--- a/js/guilds.js
+++ b/js/guilds.js
@@ -6,7 +6,7 @@ let Utilities;
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
Settings = result.PolyPlus_Settings;
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
(async () => {
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default;
@@ -40,7 +40,7 @@ const observer = new MutationObserver(async function (list) {
for (const record of list) {
for (const element of record.addedNodes) {
if (element.tagName === 'DIV' && element.classList.value === 'col-auto mb-3') {
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice(element);
}
}
diff --git a/js/library-download.js b/js/library-download.js
index 8dc5dd1..797bb18 100644
--- a/js/library-download.js
+++ b/js/library-download.js
@@ -1,8 +1,8 @@
const AssetID = window.location.pathname.split('/')[2];
-const LibraryType = document.querySelectorAll('ol a')[1].innerText;
-const LibraryTypes = ['Models', 'Audio', 'Decal', 'Mesh'];
+const LibraryType = document.querySelectorAll('ol a')[1].innerText.toLowerCase();
+const LibraryTypes = ['model', 'audio', 'decal', 'mesh'];
-if (LibraryTypes.indexOf(LibraryType) !== -1) {
+if (LibraryTypes.filter((x) => !LibraryTypes.some(element => element.startsWith(LibraryType))).length > 0) {
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
Settings = result.PolyPlus_Settings || {};
@@ -19,21 +19,21 @@ if (LibraryTypes.indexOf(LibraryType) !== -1) {
Dropdown.insertBefore(DownloadLink, Dropdown.children[Dropdown.children.length - 1]);
switch (LibraryType) {
- case 'Models':
+ case LibraryType.startsWith('model'):
DownloadLink.href = 'https://api.polytoria.com/v1/models/get-model?id=' + AssetID;
break;
- case 'Audio':
+ case LibraryType.startsWith('audio'):
const AudioBlob = new Blob([document.getElementsByTagName('audio')[0]], {type: 'octet-steam'});
DownloadLink.href = URL.createObjectURL(AudioBlob);
DownloadLink.download = document.getElementsByTagName('h1')[0].innerText + '.mp3';
- case 'Decal':
+ case LibraryType.startsWith('decal'):
const DecalBlob = new Blob([document.getElementsByClassName('store-thumbnail')[0]], {type: 'image/png'});
DownloadLink.href = URL.createObjectURL(DecalBlob);
DownloadLink.download = document.getElementsByTagName('h1')[0].innerText + '.png';
break;
}
- if (LibraryType === 'Mesh') {
+ if (LibraryType.startsWith('mesh')) {
let MeshURL = null;
DownloadLink.addEventListener('click', async function () {
if (MeshURL !== null) {
diff --git a/js/places/place-view.js b/js/places/place-view.js
index 3e28c2c..b0ec5d7 100644
--- a/js/places/place-view.js
+++ b/js/places/place-view.js
@@ -67,7 +67,7 @@ const Gamepasses = Array.from(GamepassesTab.getElementsByClassName('card')) || [
}
}
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice();
}
diff --git a/js/sitewide.js b/js/sitewide.js
index a6c4091..bd46c30 100755
--- a/js/sitewide.js
+++ b/js/sitewide.js
@@ -11,7 +11,7 @@ let Theme = ``;
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
// If theme exists, create a style element to represent it
- if (Settings.ThemeCreator.Enabled && Settings.ThemeCreator.Enabled === true) {
+ if (Settings.ThemeCreator && Settings.ThemeCreator.Enabled === true) {
switch (Settings.ThemeCreator.BGImageSize) {
case 0:
Settings.ThemeCreator.BGImageSize = 'fit';
@@ -113,8 +113,8 @@ let Theme = ``;
}
});
- if (Settings.HideUserAds.Enabled === true) {
- if (Settings.HideUserAds.Banners === true) {
+ if (Settings.HideUserAds && Settings.HideUserAds.Enabled === true) {
+ if (Settings.HideUserAds.Banners && Settings.HideUserAds.Banners === true) {
Theme += `
div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
display: none;
@@ -122,7 +122,7 @@ let Theme = ``;
`;
}
- if (Settings.HideUserAds.Rectangles === true) {
+ if (Settings.HideUserAds.Rectangles && Settings.HideUserAds.Rectangles === true) {
Theme += `
div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
display: none;
@@ -154,7 +154,7 @@ let Theme = ``;
const UserData = JSON.parse(window.localStorage.getItem('p+account_info'));
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
const IRLResult = await Utilities.CalculateIRL(document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g, ''), Settings.IRLPriceWithCurrency.Currency);
// Desktop
document.querySelector('.text-success .brickBalanceCount').innerHTML += ` (${IRLResult.icon}${IRLResult.result} ${IRLResult.display})`;
diff --git a/js/store/item-view.js b/js/store/item-view.js
index c4beff3..f8674ae 100755
--- a/js/store/item-view.js
+++ b/js/store/item-view.js
@@ -31,7 +31,7 @@ var Utilities;
Utilities.InjectResource('registerTooltips');
}
- if (Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
IRLPrice();
}
@@ -54,11 +54,10 @@ var Utilities;
}
if (document.getElementById('resellers') !== null) {
- if (Settings.HoardersList.Enabled === true) {
- console.log(parseInt(Settings.HoardersList.MinCopies));
+ if (Settings.HoardersList && Settings.HoardersList.Enabled === true) {
HoardersList(parseInt(Settings.HoardersList.MinCopies), Settings.HoardersList.AvatarsEnabled);
}
- } else if (document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) {
+ } else if (Settings.ItemOwnerCheckOn === true && document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) {
CheckOwner();
}
});
@@ -301,16 +300,17 @@ function TryOnItems() {
TryOnModal.classList = 'polyplus-modal';
TryOnModal.setAttribute('style', 'width: 450px; border: 1px solid #484848; background-color: #181818; border-radius: 20px; overflow: hidden;');
TryOnModal.innerHTML = `
-
-
-
Preview
- Try this avatar on your avatar before purchasing it!
-
-
-
-
-
-
+
+
+
Preview
+ Try this avatar on your avatar before purchasing it!
+
+
+
+
+
+
+
`;
document.body.prepend(TryOnModal);
@@ -400,16 +400,27 @@ async function HoardersList(min, avatars) {
}
}
+ let AvatarsFetched = 0;
let Hoarders = await new Promise(async (resolve, reject) => {
- const Sorted = Object.values(Formatted)
- .filter((x, index) => x.copies >= min)
- .sort((a, b) => b.copies - a.copies);
+ const FormattedValues = Object.values(Formatted).filter((x, index) => x.copies >= 2)
if (avatars === true) {
- for (let hoarder of Sorted) {
- const Avatar = (await (await fetch('https://api.polytoria.com/v1/users/' + hoarder.user.id)).json()).thumbnail.icon;
- hoarder.user.avatar = Avatar;
+ for (let hoarder of FormattedValues) {
+ if (AvatarsFetched < 15) {
+ try {
+ AvatarsFetched++
+ const Avatar = (await (await fetch('https://api.polytoria.com/v1/users/' + hoarder.user.id)).json());
+ console.log(hoarder.user.username, Avatar)
+ hoarder.user.avatar = Avatar.thumbnail.icon;
+ } catch(error) {
+ hoarder.user.avatar = ''
+ console.log(hoarder.user.username + ` (${hoarder.user.id}) - avatar failed`)
+ }
+ }
}
}
+ const Sorted = FormattedValues
+ .filter((x, index) => x.copies >= min)
+ .sort((a, b) => b.copies - a.copies);
resolve(Sorted);
});
let AmountOfHoarders = Hoarders.length;
@@ -421,91 +432,79 @@ async function HoardersList(min, avatars) {
}
TabContent.innerHTML = `
-
- ${
- Groups[Page] !== undefined
- ? Groups[Page].map(
- (x) => `
-
-
-
- ${
- avatars === true
- ? `
-
-

-
- `
- : ''
+
+ ${ Groups[Page] !== undefined ? Groups[Page].map((x) => `
+
+
+
+ ${ avatars === true ? `
+
+

+
+ ` : ''
}
-
-
-
-
-
- `
- ).join('')
- : `
-
-
-
-
No hoarders
-
This item is fresh and doesn't have any hoarders yet! Come back later!
-
-
- `
- }
-
-
- `;
+
+
+
+
+
+ `
+ ).join('') : `
+
+
+
+
No hoarders
+
This item is fresh and doesn't have any hoarders yet! Come back later!
+
+
+ `}
+
+
+ feature of Poly+
+ `;
Utilities.InjectResource('registerTooltips');
const Container = document.getElementById('p+hoarders-container');
@@ -582,53 +581,47 @@ async function HoardersList(min, avatars) {
Current.innerText = Page + 1;
if (Groups[Page] !== undefined) {
- Container.innerHTML = Groups[Page].map(
- (x) => `
-
-
-
- ${
- avatars === true
- ? `
-
-

-
- `
- : ''
+ Container.innerHTML = Groups[Page].map((x) => `
+
+
+
+ ${ avatars === true ? `
+
+

+
+ ` : ''
}
-
-
-
-
-
- `
+
+
+
+
+
+ `
).join('');
Utilities.InjectResource('registerTooltips');
} else {
Container.innerHTML = `
-
-
-
-
No hoarders
-
This item is fresh and doesn't have any hoarders yet! Come back later!
-
-
- `;
-
- MinCopies.disabled = true;
+
+
+
+
No hoarders
+
This item is fresh and doesn't have any hoarders yet! Come back later!
+
+
+ `;
}
if (Page > 0) {
diff --git a/js/store/store.js b/js/store/store.js
index bfb7feb..f8d5b3d 100755
--- a/js/store/store.js
+++ b/js/store/store.js
@@ -15,7 +15,7 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) {
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default;
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
Array.from(ItemGrid.children).forEach((element) => {
LoadIRLPrices(element);
});
@@ -59,7 +59,7 @@ const observer = new MutationObserver(async function (list) {
for (const record of list) {
for (const element of record.addedNodes) {
if (element.tagName === 'DIV' && element.classList.value === 'mb-3 itemCardCont') {
- if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
LoadIRLPrices(element);
}
diff --git a/package-lock.json b/package-lock.json
deleted file mode 100644
index 946a311..0000000
--- a/package-lock.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "name": "PolyPlus",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "": {
- "devDependencies": {
- "prettier": "^3.2.5",
- "prettier-plugin-jinja-template": "^1.4.0"
- }
- },
- "node_modules/prettier": {
- "version": "3.2.5",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
- "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
- "dev": true,
- "bin": {
- "prettier": "bin/prettier.cjs"
- },
- "engines": {
- "node": ">=14"
- },
- "funding": {
- "url": "https://github.com/prettier/prettier?sponsor=1"
- }
- },
- "node_modules/prettier-plugin-jinja-template": {
- "version": "1.4.0",
- "resolved": "https://registry.npmjs.org/prettier-plugin-jinja-template/-/prettier-plugin-jinja-template-1.4.0.tgz",
- "integrity": "sha512-9i7HwTAryhOTtY1ENyZBZA+KNaPphSaI/sXbQno5a6/DgiP6ZAnUiax4cOKiutEwiSDhVfLbTXEfHS5QAUVWBg==",
- "dev": true,
- "peerDependencies": {
- "prettier": "^3.0.0"
- }
- }
- }
-}
diff --git a/package.json b/package.json
deleted file mode 100644
index a8fab87..0000000
--- a/package.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "scripts": {
- "format": "prettier --write ."
- },
- "devDependencies": {
- "prettier": "^3.2.5",
- "prettier-plugin-jinja-template": "^1.4.0"
- }
-}
diff --git a/resources/utils.js b/resources/utils.js
index fd71cb5..80f7732 100644
--- a/resources/utils.js
+++ b/resources/utils.js
@@ -109,15 +109,15 @@ export default {
TextureTypes: ['shirt', 'pants', 'face'],
CalculateIRL: async function (bricks, to, brickPackage) {
/*
- Disabled for now: currency retrieval from currencies.json
+ Disabled for now: currency retrieval from currencies.json
- const response = await fetch(chrome.runtime.getURL('resources/currencies.json'))
- if (!response.ok) {
- throw new Error('Getting currency data failure')
- }
- const data = await response.json()
- const UnitPrice = data.Data[brickPackage][to]
- */
+ const response = await fetch(chrome.runtime.getURL('resources/currencies.json'))
+ if (!response.ok) {
+ throw new Error('Getting currency data failure')
+ }
+ const data = await response.json()
+ const UnitPrice = data.Data[brickPackage][to]
+ */
let Icon = '$';
let Result = 'N/A';
@@ -212,10 +212,17 @@ export default {
};
},
InjectResource: function (path, element) {
- // Function by devjin0617 on GitHub
- // Gist: https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a
- // Slightly modified to use constants and fit the rest of the code style more
- // Function only used for registering bootstrap tooltips currently
+ /*
+ Function by devjin0617 on GitHub
+ Gist: https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a
+ Slightly modified to use constants and fit the rest of the code style more
+ Function only used for registering bootstrap tooltips and getting the signed-in user's username, user ID, and brick count currently
+ */
+
+ /*
+ Potentially make this use chrome.runtime.sendMessage in the background.js script soon
+ */
+
if (element === undefined) {
element = 'body';
diff --git a/settings.js b/settings.js
index 070c2b6..f074e23 100644
--- a/settings.js
+++ b/settings.js
@@ -1,6 +1,7 @@
const SaveBtn = document.getElementById('Save');
const Elements = Array.from(document.getElementsByClassName('setting-container'));
+var RecentSave;
var Settings;
var Utilities;
@@ -12,16 +13,14 @@ var Utilities;
document.getElementById('PinnedGames-limit').innerText = Utilities.Limits.PinnedGames;
document.getElementById('BestFriends-limit').innerText = Utilities.Limits.BestFriends;
document.getElementById('ImprovedFrLists-limit').innerText = Utilities.Limits.ImprovedFrLists;
- document.getElementById('ItemWishlist-limit').innerText = Utilities.Limits.ItemWishlist;
+ //document.getElementById('ItemWishlist-limit').innerText = Utilities.Limits.ItemWishlist;
})();
// Handle buttons at the bottom of the page
document.getElementById('ResetDefaults').addEventListener('click', function () {
document.getElementById('ResetDefaults-Modal').showModal();
});
-SaveBtn.addEventListener('click', function () {
- Save();
-});
+SaveBtn.addEventListener('click', Save);
// Handle modal buttons for Reset Defaults modal
document.getElementById('ResetDefaults-Modal-Yes').addEventListener('click', function () {
@@ -36,16 +35,8 @@ document.getElementById('ResetDefaults-Modal-No').addEventListener('click', func
document.getElementById('ResetDefaults-Modal').close();
});
-// Handle leaving the settings page before saving
-window.onbeforeunload = function () {
- if (SaveBtn.getAttribute('disabled') !== undefined) {
- return "Are you sure you'd like to leave? Your Poly+ settings haven't been saved.";
- }
-};
-
// Loop thru each setting container and handle toggling, selecting, opening modal, etc
Elements.forEach((element) => {
- console.log('Handle Element', element);
let Button = element.getElementsByTagName('button')[0];
let Options = element.getElementsByTagName('button')[1];
let Select = element.getElementsByTagName('select')[0];
@@ -93,16 +84,20 @@ Elements.forEach((element) => {
if (Setting === '[save]') {
// Save Modal Button
+ // Save Modal Inputs
Array.from(ModalInputs)
.filter((x) => !x.classList.contains('ignore'))
.forEach((input) => {
SetSetting(input, input.value, false, Modal.getAttribute('data-setting'));
});
+
+ // Save Modal Select Menus
Array.from(ModalSelect)
.filter((x) => !x.classList.contains('ignore'))
.forEach((select) => {
SetSetting(select, select.selectedIndex, false, Modal.getAttribute('data-setting'));
});
+
Save();
setTimeout(function () {
LoadCurrent();
@@ -156,17 +151,18 @@ Elements.forEach((element) => {
function LoadCurrent() {
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
Settings = MergeObjects(result.PolyPlus_Settings || Utilities.DefaultSettings, Utilities.DefaultSettings);
+ RecentSave = structuredClone(Settings)
console.log('Current Settings: ', Settings);
Elements.forEach((element) => {
- console.log('For Each Update');
UpdateElementState(element);
});
});
}
function SetSetting(element, value, update, modalParent) {
+ document.title = '*unsaved | Poly+ Settings'
const name = element.getAttribute('data-setting');
let parent = element.getAttribute('data-parent');
@@ -181,7 +177,6 @@ function SetSetting(element, value, update, modalParent) {
if (parent !== null) {
let Parent = Object.values(Settings)[Object.keys(Settings).indexOf(parent)];
if (!isNaN(element.getAttribute('data-parent')) && element.getAttribute('data-parent') !== null) {
- console.log('is numbere!!!!');
Parent = Parent[parseInt(element.getAttribute('data-parent'))];
}
Parent[name] = value;
@@ -193,11 +188,16 @@ function SetSetting(element, value, update, modalParent) {
}
if (SaveBtn.getAttribute('disabled')) {
SaveBtn.removeAttribute('disabled');
- }
- const getInObject = function (a, b) {
- return Object.values(a)[Object.keys(a).indexOf(b)];
- };
+ // Handle leaving the settings page before saving
+ window.onbeforeunload = function (e) {
+ return "Are you sure you'd like to leave? Your Poly+ settings haven't been saved."
+ };
+ }
+ if (AreIdentical(Settings, RecentSave) === true) {
+ document.title = 'Poly+ Settings'
+ SaveBtn.disabled = true
+ }
}
function GetSettingValue(element, modalParent) {
@@ -217,40 +217,31 @@ function GetSettingValue(element, modalParent) {
} else {
Status = Object.values(Parent)[Object.keys(Parent).indexOf(name)];
}
-
- /*
- if (!isNaN(element.getAttribute('data-parent'))) {
- Parent = Parent[parseInt(element.getAttribute('data-parent'))]
- }
- Status = Object.values(Parent)[Object.keys(Parent).indexOf(Status)]
- */
} else {
Status = Settings[Status];
}
- console.log('Get Value Result', Status);
+
+ if (element.tagName === 'SELECT' && element.getAttribute('data-useValue') === 'true') {
+ Status = Array.from(element.children).indexOf(element.querySelector('option[value="' + Status + '"]'))
+ }
return Status;
}
function UpdateElementState(element, status) {
- console.log('Update Element State', element, status);
-
const Button = element.getElementsByClassName('toggle-btn')[0];
if (status === undefined) {
- console.log('Update Element State, no status provided');
status = GetSettingValue(Button);
}
if (status === true) {
- console.log('Is Enabled so Set False');
element.classList.add('enabled');
element.classList.remove('disabled');
Button.innerText = 'Disable';
Button.classList.add('btn-danger');
Button.classList.remove('btn-success');
} else {
- console.log('Is Disabled so Set True');
element.classList.add('disabled');
element.classList.remove('enabled');
Button.innerText = 'Enable';
@@ -260,15 +251,12 @@ function UpdateElementState(element, status) {
let SelectInput = element.getElementsByTagName('select')[0];
if (SelectInput) {
- console.log('Select Found');
SelectInput.selectedIndex = GetSettingValue(SelectInput);
}
let Checkbox = Array.from(element.getElementsByTagName('input'));
if (Checkbox.length > 0) {
- console.log('Checkbox/Input(s) Found', Checkbox);
Checkbox.forEach((check) => {
- console.log('check', GetSettingValue(check));
check.checked = GetSettingValue(check);
});
}
@@ -277,10 +265,14 @@ function UpdateElementState(element, status) {
function Save() {
document.title = 'Poly+ Settings';
SaveBtn.setAttribute('disabled', 'true');
- chrome.storage.sync.set({PolyPlus_Settings: Settings, arrayOrder: true}, function () {
+ chrome.storage.sync.set({PolyPlus_Settings: Settings}, function () {
console.log('Saved successfully!');
+ RecentSave = Settings
});
+ // Handle leaving the settings page after saving
+ window.onbeforeunload = null
+
console.log('Save:', Settings);
}
@@ -353,6 +345,11 @@ function MergeObjects(obj1, obj2) {
return mergedObj;
}
+function AreIdentical(obj1, obj2) {
+ if (obj1.length !== obj2.length) { return false }
+ return JSON.stringify(obj1) === JSON.stringify(obj2)
+}
+
function FormatBool(bool) {
if (bool === true) {
return 'enabled';
@@ -397,6 +394,7 @@ function CheckForUpdates() {
}
CheckForUpdatesButton.addEventListener('click', CheckForUpdates);
+/*
fetch(chrome.runtime.getURL('resources/currencies.json'))
.then((response) => {
if (!response.ok) {
@@ -411,6 +409,7 @@ fetch(chrome.runtime.getURL('resources/currencies.json'))
.catch((error) => {
console.log(error);
});
+*/
chrome.storage.local.get(['PolyPlus_OutOfDate', 'PolyPlus_LiveVersion', 'PolyPlus_ReleaseNotes', 'PolyPlus_SkipUpdate'], function (result) {
const OutOfDate = result.PolyPlus_OutOfDate || false;