diff --git a/js/background.js b/js/background.js
index fda2dbf..23d5b76 100755
--- a/js/background.js
+++ b/js/background.js
@@ -98,7 +98,14 @@ const DefaultSettings = {
},
ReaddCopyablePlacesOn: true,
TimePlayedOn: true,
- HomeJoinFriendsButtonOn: true
+ HomeJoinFriendsButtonOn: true,
+ ImprovedPlaceManagement: {
+ Enabled: true,
+ QuickActivityToggleOn: true,
+ PlaceFileDownloadOn: true,
+ MultiWhitelistOn: true,
+ ClearWhitelistOn: true
+ }
}
// ON EXTENSION INSTALL / RELOAD
diff --git a/js/places/place-edit.js b/js/create/place-access.js
similarity index 52%
rename from js/places/place-edit.js
rename to js/create/place-access.js
index c1cf72d..6223a3f 100755
--- a/js/places/place-edit.js
+++ b/js/create/place-access.js
@@ -4,10 +4,41 @@ const Form = document.querySelector('form[action="/create/place/update"]');
var Settings;
var PlaceData = null;
+let Utilities;
+
!(async () => {
- ActivityToggle();
- //RequestGameProfile()
- CopyOwnedPlace();
+ Utilities = (await import(chrome.runtime.getURL('resources/utils.js')))
+ .default;
+
+ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
+ Settings = result.PolyPlus_Settings || {
+ ImprovedPlaceManagement: {
+ Enabled: true,
+ QuickActivityToggleOn: true,
+ PlaceFileDownloadOn: true,
+ MultiWhitelistOn: true,
+ ClearWhitelistOn: true
+ }
+ }
+
+ if (Settings.ImprovedPlaceManagement.Enabled) {
+ if (Settings.ImprovedPlaceManagement.QuickActivityToggleOn && Settings.ImprovedPlaceManagement.QuickActivityToggleOn === true) {
+ ActivityToggle();
+ }
+
+ if (Settings.ImprovedPlaceManagement.PlaceFileDownloadOn && Settings.ImprovedPlaceManagement.PlaceFileDownloadOn === true) {
+ CopyOwnedPlace();
+ }
+
+ if (Settings.ImprovedPlaceManagement.MultiWhitelistOn && Settings.ImprovedPlaceManagement.MultiWhitelistOn === true) {
+ MultiWhitelist();
+ }
+
+ if (Settings.ImprovedPlaceManagement.ClearWhitelistOn && Settings.ImprovedPlaceManagement.ClearWhitelistOn === true) {
+ ClearWhitelist();
+ }
+ }
+ })
})();
async function ActivityToggle() {
@@ -141,3 +172,103 @@ async function CopyOwnedPlace() {
});
});
}
+
+function MultiWhitelist(){
+ const WhitelistCard = document.querySelector('.card:has(#whitelist-username)')
+
+ const MultiWhitelistCard = document.createElement('card')
+ MultiWhitelistCard.classList = 'card mt-3'
+ MultiWhitelistCard.innerHTML = `
+
+
+
+
+
+ `
+ WhitelistCard.parentElement.appendChild(MultiWhitelistCard)
+
+ const MultiWhitelistSubmitButton = MultiWhitelistCard.getElementsByTagName('button')[0]
+
+ MultiWhitelistSubmitButton.addEventListener('click', async function(){
+ const Usernames = MultiWhitelistSubmitButton.previousElementSibling.value.split('\n').filter((x) => x !== "")
+ MultiWhitelistSubmitButton.previousElementSibling.disabled = true
+ if (Usernames.length > 0) {
+ for (let username of Usernames) {
+ const WhitelistAddRequest = (await (await fetch('https://polytoria.com/api/create/whitelist', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ placeID: PlaceID,
+ username: username
+ })
+ })).json())
+ }
+
+ window.location.reload()
+ }
+ })
+}
+
+function ClearWhitelist() {
+ const WhitelistCard = document.querySelector('.card:has(#whitelist-username)')
+
+ const ClearWhitelistButton = document.createElement('button')
+ ClearWhitelistButton.classList = 'btn btn-danger btn-sm'
+ ClearWhitelistButton.style = 'position: absolute; top: 0; right: 0; margin: 4px;'
+ ClearWhitelistButton.innerHTML = ' Clear'
+ WhitelistCard.children[0].appendChild(ClearWhitelistButton)
+
+ let WhitelistData = null
+ let ClearPending = false
+ ClearWhitelistButton.addEventListener('click', async function(){
+ if (ClearPending === false) {
+ ClearPending = true
+ ClearWhitelistButton.innerText = 'Are you sure?'
+ setTimeout(() => {
+ if (ClearPending === true) {
+ ClearPending = false;
+ ClearWhitelistButton.innerHTML = ' Clear'
+ }
+ }, 3000);
+ } else {
+ ClearPending = false
+ ClearWhitelistButton.innerHTML = ' Clear'
+ if (confirm('Are you sure you\'d like to clear all of this place\'s whitelist')) {
+ if (WhitelistData === null) {
+ const InitialWhitelist = (await (await fetch('https://polytoria.com/api/create/whitelist?placeID=' + PlaceID + '&page=1')).json())
+ WhitelistData = [...InitialWhitelist.data]
+
+ if (InitialWhitelist.meta.lastPage > 1) {
+ for (let page = 1; page < InitialWhitelist.meta.lastPage; page++) {
+ const PageResult = (await (await fetch('https://polytoria.com/api/create/whitelist?placeID=' + PlaceID + '&page=' + (page+1))).json())
+ WhitelistData.push(...PageResult.data)
+ }
+ }
+
+ for (let id of WhitelistData.map((x) => x.user.id)) {
+ Utilities.RatelimitRepeatingFetch('https://polytoria.com/api/create/remove-whitelist', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ placeID: PlaceID,
+ userID: id
+ })
+ })
+ }
+
+ window.location.reload()
+ }
+ }
+ }
+ })
+}
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 6063e5a..cb4d248 100644
--- a/manifest.json
+++ b/manifest.json
@@ -33,8 +33,8 @@
},
{
- "matches": ["https://polytoria.com/create/place/**"],
- "js": ["/js/places/place-edit.js"]
+ "matches": ["https://polytoria.com/create/place/**/access"],
+ "js": ["/js/create/place-access.js"]
},
{
diff --git a/resources/utils.js b/resources/utils.js
index 9ed0143..de22657 100644
--- a/resources/utils.js
+++ b/resources/utils.js
@@ -117,7 +117,14 @@ export default {
OpacityOn: true
},
TimePlayedOn: true,
- HomeJoinFriendsButtonOn: true
+ HomeJoinFriendsButtonOn: true,
+ ImprovedPlaceManagement: {
+ Enabled: true,
+ QuickActivityToggleOn: true,
+ PlaceFileDownloadOn: true,
+ MultiWhitelistOn: true,
+ ClearWhitelistOn: true
+ }
},
Limits: {
PinnedGames: 10,
diff --git a/settings.html b/settings.html
index 201765a..47cd829 100755
--- a/settings.html
+++ b/settings.html
@@ -810,6 +810,37 @@
Quickly join your friends' servers by clicking the play button inside the tooltip in the "Friends" section of the homepage.
+
+
Now a Setting!
+
+
+
+ Improved Place Management
+
+
+
+
+
+
+ Develop the next hit game easier with a few management tools!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+