irl price on resellers and no more pagination on item wishlist and collectibles

This commit is contained in:
Index 2024-06-26 11:48:27 -05:00
parent 9457437ba6
commit deeaba05b2
6 changed files with 268 additions and 82 deletions

View file

@ -222,7 +222,6 @@ async function UpdateAvatar() {
if (ItemCache[x] === undefined) { if (ItemCache[x] === undefined) {
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json()) const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
ItemCache[x] = { ItemCache[x] = {
/*
type: ItemDetails.type, type: ItemDetails.type,
name: ItemDetails.name, name: ItemDetails.name,
price: ItemDetails.price, price: ItemDetails.price,
@ -231,7 +230,6 @@ async function UpdateAvatar() {
id: ItemDetails.creator.id id: ItemDetails.creator.id
}, },
thumbnail: ItemDetails.thumbnail, thumbnail: ItemDetails.thumbnail,
*/
asset: undefined asset: undefined
} }

View file

@ -1,3 +1,7 @@
/*
Proper pagination will be added in v1.2.3
*/
Username = window.location.pathname.split('/')[2]; Username = window.location.pathname.split('/')[2];
let UserID; let UserID;
let ItemGrid; let ItemGrid;
@ -7,19 +11,19 @@ if (window.location.pathname.split('/')[3] === 'inventory') {
UserID = (await (await fetch('https://api.polytoria.com/v1/users/find?username=' + Username )).json()).id; UserID = (await (await fetch('https://api.polytoria.com/v1/users/find?username=' + Username )).json()).id;
ItemGrid = document.getElementsByClassName('itemgrid')[0]; ItemGrid = document.getElementsByClassName('itemgrid')[0];
chrome.storage.sync.get(['PolyPlus_Settings', 'PolyPlus_ItemWishlist'], function(result){ /*
Rewritten item wishlist function will take in the data with a parameter instead
*/
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
Settings = result.PolyPlus_Settings Settings = result.PolyPlus_Settings
const Nav = document.getElementsByClassName('nav-pills')[0]; const Nav = document.getElementsByClassName('nav-pills')[0];
if (Settings.ItemWishlistOn if (Settings.ItemWishlistOn && Username === JSON.parse(window.localStorage.getItem('p+account_info')).Username) {
&& Username === JSON.parse(window.localStorage.getItem('p+account_info')).Username
&& window.location.pathname.split('/')[4] === 'wishlist'
) {
let WishlistNav = document.createElement('li'); let WishlistNav = document.createElement('li');
WishlistNav.classList.add('nav-item'); WishlistNav.classList.add('nav-item');
WishlistNav.innerHTML = ` WishlistNav.innerHTML = `
<a href="wishlist/" class="nav-link"> <a href="${ (window.location.pathname.split('/')[4] !== '') ? '../wishlist/' : 'wishlist/' }" class="nav-link">
<i class="fa-regular fa-list me-1"></i> <i class="fa-regular fa-list me-1"></i>
<span class="pilltitle">Item Wishlist</span> <span class="pilltitle">Item Wishlist</span>
</a> </a>
@ -45,7 +49,7 @@ if (window.location.pathname.split('/')[3] === 'inventory') {
let CollectibleNav = document.createElement('li'); let CollectibleNav = document.createElement('li');
CollectibleNav.classList.add('nav-item'); CollectibleNav.classList.add('nav-item');
CollectibleNav.innerHTML = ` CollectibleNav.innerHTML = `
<a href="collectibles/" class="nav-link"> <a href="${ (window.location.pathname.split('/')[4] !== '') ? '../collectibles/' : 'collectibles/' }" class="nav-link">
<i class="fa-regular fa-sparkles me-1"></i> <i class="fa-regular fa-sparkles me-1"></i>
<span class="pilltitle">Collectibles</span> <span class="pilltitle">Collectibles</span>
</a> </a>
@ -70,6 +74,9 @@ if (window.location.pathname.split('/')[3] === 'inventory') {
})(); })();
} }
/*
Item Wishlist will be rewritten in v1.2.3
*/
function ItemWishlist() { function ItemWishlist() {
const ItemGrid = document.getElementsByClassName('itemgrid')[0]; const ItemGrid = document.getElementsByClassName('itemgrid')[0];
const ItemCardContents = ` const ItemCardContents = `
@ -91,6 +98,7 @@ function ItemWishlist() {
`; `;
ItemGrid.innerHTML = '' ItemGrid.innerHTML = ''
document.getElementsByClassName('pagination')[0].remove()
const Search = document.createElement('div'); const Search = document.createElement('div');
Search.classList = 'row'; Search.classList = 'row';
Search.innerHTML = ` Search.innerHTML = `
@ -111,8 +119,8 @@ function ItemWishlist() {
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="polyplus-itemwish-isLimited"> <input class="form-check-input" type="checkbox" value="" id="polyplus-itemwish-isLimited">
<label class="form-check-label" for="polyplus-itemwish-isLimited"> <label class="form-check-label" for="polyplus-itemwish-isLimited">
Is Limited? Is Collectible?
<span class="text-muted" style="font-size: 0.65rem; display: block;">Items that are limited</span> <span class="text-muted" style="font-size: 0.65rem; display: block;">Items that are collectible</span>
</label> </label>
</div> </div>
</div> </div>
@ -156,7 +164,7 @@ function ItemWishlist() {
Wishlist.forEach((element) => { Wishlist.forEach((element) => {
let NewItemCard = document.createElement('div'); let NewItemCard = document.createElement('div');
NewItemCard.classList = 'px-0'; NewItemCard.classList = 'px-0';
fetch('https://api.polytoria.com/v1/store/:id'.replace(':id', element)) fetch('https://api.polytoria.com/v1/store/' + element)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
NewItemCard.innerHTML = ItemCardContents.replace(':ItemID', data.id) NewItemCard.innerHTML = ItemCardContents.replace(':ItemID', data.id)
@ -200,7 +208,6 @@ function ItemWishlist() {
}); });
}); });
}); });
}
const Update = function(type, query, isLimited, isAvailable) { const Update = function(type, query, isLimited, isAvailable) {
let ItemGrid = document.getElementsByClassName('itemgrid')[0]; let ItemGrid = document.getElementsByClassName('itemgrid')[0];
@ -241,9 +248,11 @@ const Update = function(type, query, isLimited, isAvailable) {
} }
} }
} }
}
async function CollectibleCategory() { async function CollectibleCategory() {
ItemGrid.innerHTML = '' ItemGrid.innerHTML = ''
document.getElementsByClassName('pagination')[0].remove()
const CollectibleItemTypes = [ const CollectibleItemTypes = [
"hat", "hat",
"face", "face",

View file

@ -12,7 +12,7 @@ let Utilities;
if (Username) { if (Username) {
(async () => { (async () => {
UserID = (await (await fetch('https://api.polytoria.com/v1/users/find?username=' + Username )).json()); UserID = (await (await fetch('https://api.'+window.location.hostname+'/v1/users/find?username=' + Username )).json());
Utilities = await import(chrome.runtime.getURL('resources/utils.js')); Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default; Utilities = Utilities.default;

View file

@ -31,7 +31,7 @@ var Utilities;
Utilities.InjectResource('registerTooltips'); Utilities.InjectResource('registerTooltips');
} }
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) { if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice(); IRLPrice();
} }
@ -96,9 +96,7 @@ chrome.storage.onChanged.addListener(function (changes, namespace) {
async function IRLPrice() { async function IRLPrice() {
const Price = PurchaseBtn.getAttribute('data-price'); const Price = PurchaseBtn.getAttribute('data-price');
if (Price === null || Price === '0') { if (Price !== null && Price !== '0') {
return;
}
const Span = document.createElement('span'); const Span = document.createElement('span');
Span.classList = 'text-muted polyplus-own-tag'; Span.classList = 'text-muted polyplus-own-tag';
Span.style.fontSize = '0.7rem'; Span.style.fontSize = '0.7rem';
@ -108,6 +106,29 @@ async function IRLPrice() {
PurchaseBtn.appendChild(Span); PurchaseBtn.appendChild(Span);
} }
const Resellers = document.getElementById('resellers-container')
if (Resellers !== null) {
const observer = new MutationObserver(async function (list) {
for (const record of list) {
for (const element of record.addedNodes) {
if (element.tagName === 'DIV') {
const ResellerSpan = document.createElement('span');
ResellerSpan.classList = 'text-muted polyplus-own-tag';
ResellerSpan.style.fontSize = '0.7rem';
ResellerSpan.style.fontWeight = 'normal';
const ResellerIRLResult = await Utilities.CalculateIRL(element.getElementsByClassName('text-success')[0].innerText, Settings.IRLPriceWithCurrency.Currency);
ResellerSpan.innerText = ' ($' + ResellerIRLResult.result + ' ' + ResellerIRLResult.display + ')';
element.getElementsByClassName('text-success')[0].appendChild(ResellerSpan);
}
}
observer.observe(Resellers, {attributes: false, childList: true, subtree: false});
}
});
observer.observe(Resellers, {attributes: false, childList: true, subtree: false});
}
}
function HandleItemWishlist() { function HandleItemWishlist() {
const DescriptionText = document.querySelector('.mcard .card-body:has(p)'); const DescriptionText = document.querySelector('.mcard .card-body:has(p)');
WishlistBtn = document.createElement('button'); WishlistBtn = document.createElement('button');

158
manifest-old.json Normal file
View file

@ -0,0 +1,158 @@
{
"manifest_version": 3,
"author": "Index",
"name": "Poly+",
"version": "1.21",
"version_name": "Pre-Release Build (v1.2.1)",
"description": "Power-up your Polytoria experience with Poly+! Created by Index.",
"homepage_url": "https://polyplus.vercel.app/",
"permissions": ["storage", "contextMenus", "scripting", "alarms", "notifications"],
"content_scripts": [
{
"matches": ["https://polytoria.com/*"],
"js": ["/js/sitewide.js", "/js/membership-themes.js"],
"css": ["/css/specific.css"],
"run_at": "document_start"
},
{
"matches": ["https://polytoria.com/my/settings/*"],
"js": ["/js/settings.js", "/js/extra-pages.js"],
"run_at": "document_start"
},
{
"matches": ["https://polytoria.com/", "https://polytoria.com/home"],
"js": ["/js/account/home.js"],
"run_at": "document_idle"
},
{
"matches": ["https://polytoria.com/places/**"],
"js": ["/js/places/place-view.js"]
},
{
"matches": ["https://polytoria.com/create/place/**"],
"js": ["/js/places/place-edit.js"]
},
{
"matches": ["https://polytoria.com/create/image", "https://polytoria.com/create/image/"],
"js": ["/js/create/image.js"]
},
{
"matches": ["https://polytoria.com/forum/post/**"],
"js": ["/js/forum/forum-view.js"]
},
{
"matches": ["https://polytoria.com/u/**", "https://polytoria.com/users/**"],
"js": ["/js/account/profile.js", "/js/account/inventory.js"]
},
{
"matches": ["https://polytoria.com/my/friends", "https://polytoria.com/my/friends/"],
"js": ["/js/account/friends.js"]
},
{
"matches": ["https://polytoria.com/store", "https://polytoria.com/store/"],
"js": ["/js/store/store.js"]
},
{
"matches": ["https://polytoria.com/store/**"],
"js": ["/js/store/item-view.js"]
},
{
"matches": ["https://polytoria.com/forum/search", "https://polytoria.com/forum/search?*"],
"js": ["/js/forum/forum-search.js"]
},
{
"matches": ["https://polytoria.com/trade/sent/*"],
"js": ["/js/account/trades-outbound.js"]
},
{
"matches": ["https://polytoria.com/u/*/inventory/"],
"js": ["/js/account/inventory.js"],
"run_at": "document_idle"
},
{
"matches": ["https://polytoria.com/my/settings/privacy"],
"js": ["/js/account/settings-privacy.js"]
},
{
"matches": ["https://polytoria.com/my/settings/transactions*"],
"js": ["/js/account/transactions.js"]
},
{
"matches": ["https://polytoria.com/store/**", "https://polytoria.com/places/**", "https://polytoria.com/guilds/**", "https://polytoria.com/feed/**"],
"js": ["/js/op-comments.js"]
},
{
"matches": ["https://polytoria.com/my/avatar*"],
"js": ["/js/account/avatar-sandbox2.js"]
},
{
"matches": ["https://polytoria.com/inbox*"],
"js": ["/js/account/inbox.js"]
},
{
"matches": ["https://polytoria.com/guilds/**"],
"js": ["/js/guilds.js"]
},
{
"matches": ["https://polytoria.com/store/**", "https://polytoria.com/models/**"],
"js": ["/js/library-download.js"]
},
{
"matches": ["https://polytoria.com/places/**", "https://polytoria.com/u/**"],
"js": ["the-great-divide.js"]
}
],
"background": {
"service_worker": "/js/background.js",
"type": "module"
},
"host_permissions": ["https://*.polytoria.com/*"],
"web_accessible_resources": [
{
"resources": ["resources/*"],
"matches": ["https://polytoria.com/*"]
},
{
"resources": ["settings.html", "settings.js"],
"matches": ["https://polytoria.com/*"]
}
],
"short_name": "Poly+",
"action": {
"default_title": "Poly+",
"default_icon": {
"16": "/images/icon.png",
"32": "/images/icon.png",
"48": "/images/icon.png",
"128": "/images/icon.png"
}
},
"icons": {
"16": "/images/icon.png",
"32": "/images/icon.png",
"48": "/images/icon.png",
"128": "/images/icon.png"
}
}

View file

@ -9,117 +9,117 @@
"permissions": ["storage", "contextMenus", "scripting", "alarms", "notifications"], "permissions": ["storage", "contextMenus", "scripting", "alarms", "notifications"],
"content_scripts": [ "content_scripts": [
{ {
"matches": ["https://polytoria.com/*"], "matches": ["https://polytoria.com/*", "https://polytoria.co/*"],
"js": ["/js/sitewide.js", "/js/membership-themes.js"], "js": ["/js/sitewide.js", "/js/membership-themes.js"],
"css": ["/css/specific.css"], "css": ["/css/specific.css"],
"run_at": "document_start" "run_at": "document_start"
}, },
{ {
"matches": ["https://polytoria.com/my/settings/*"], "matches": ["https://polytoria.com/my/settings/*", "https://polytoria.co/my/settings/*"],
"js": ["/js/settings.js", "/js/extra-pages.js"], "js": ["/js/settings.js", "/js/extra-pages.js"],
"run_at": "document_start" "run_at": "document_start"
}, },
{ {
"matches": ["https://polytoria.com/", "https://polytoria.com/home"], "matches": ["https://polytoria.com/", "https://polytoria.com/home", "https://polytoria.co/", "https://polytoria.co/home"],
"js": ["/js/account/home.js"], "js": ["/js/account/home.js"],
"run_at": "document_idle" "run_at": "document_idle"
}, },
{ {
"matches": ["https://polytoria.com/places/**"], "matches": ["https://polytoria.com/places/**", "https://polytoria.co/places/**"],
"js": ["/js/places/place-view.js"] "js": ["/js/places/place-view.js"]
}, },
{ {
"matches": ["https://polytoria.com/create/place/**"], "matches": ["https://polytoria.com/create/place/**", "https://polytoria.co/create/place/**"],
"js": ["/js/places/place-edit.js"] "js": ["/js/places/place-edit.js"]
}, },
{ {
"matches": ["https://polytoria.com/create/image", "https://polytoria.com/create/image/"], "matches": ["https://polytoria.com/create/image", "https://polytoria.com/create/image/", "https://polytoria.co/create/image", "https://polytoria.co/create/image/"],
"js": ["/js/create/image.js"] "js": ["/js/create/image.js"]
}, },
{ {
"matches": ["https://polytoria.com/forum/post/**"], "matches": ["https://polytoria.com/forum/post/**", "https://polytoria.co/forum/post/**"],
"js": ["/js/forum/forum-view.js"] "js": ["/js/forum/forum-view.js"]
}, },
{ {
"matches": ["https://polytoria.com/u/**", "https://polytoria.com/users/**"], "matches": ["https://polytoria.com/u/**", "https://polytoria.com/users/**", "https://polytoria.co/u/**", "https://polytoria.co/users/**"],
"js": ["/js/account/profile.js", "/js/account/inventory.js"] "js": ["/js/account/profile.js", "/js/account/inventory.js"]
}, },
{ {
"matches": ["https://polytoria.com/my/friends", "https://polytoria.com/my/friends/"], "matches": ["https://polytoria.com/my/friends", "https://polytoria.com/my/friends/", "https://polytoria.co/my/friends", "https://polytoria.co/my/friends/"],
"js": ["/js/account/friends.js"] "js": ["/js/account/friends.js"]
}, },
{ {
"matches": ["https://polytoria.com/store", "https://polytoria.com/store/"], "matches": ["https://polytoria.com/store", "https://polytoria.com/store/", "https://polytoria.co/store", "https://polytoria.co/store/"],
"js": ["/js/store/store.js"] "js": ["/js/store/store.js"]
}, },
{ {
"matches": ["https://polytoria.com/store/**"], "matches": ["https://polytoria.com/store/**", "https://polytoria.co/store/**"],
"js": ["/js/store/item-view.js"] "js": ["/js/store/item-view.js"]
}, },
{ {
"matches": ["https://polytoria.com/forum/search", "https://polytoria.com/forum/search?*"], "matches": ["https://polytoria.com/forum/search", "https://polytoria.com/forum/search?*", "https://polytoria.co/forum/search", "https://polytoria.co/forum/search?*"],
"js": ["/js/forum/forum-search.js"] "js": ["/js/forum/forum-search.js"]
}, },
{ {
"matches": ["https://polytoria.com/trade/sent/*"], "matches": ["https://polytoria.com/trade/sent/*", "https://polytoria.co/trade/sent/*"],
"js": ["/js/account/trades-outbound.js"] "js": ["/js/account/trades-outbound.js"]
}, },
{ {
"matches": ["https://polytoria.com/u/*/inventory/"], "matches": ["https://polytoria.com/u/*/inventory/", "https://polytoria.co/u/*/inventory/"],
"js": ["/js/account/inventory.js"], "js": ["/js/account/inventory.js"],
"run_at": "document_idle" "run_at": "document_idle"
}, },
{ {
"matches": ["https://polytoria.com/my/settings/privacy"], "matches": ["https://polytoria.com/my/settings/privacy", "https://polytoria.co/my/settings/privacy"],
"js": ["/js/account/settings-privacy.js"] "js": ["/js/account/settings-privacy.js"]
}, },
{ {
"matches": ["https://polytoria.com/my/settings/transactions*"], "matches": ["https://polytoria.com/my/settings/transactions*", "https://polytoria.co/my/settings/transactions*"],
"js": ["/js/account/transactions.js"] "js": ["/js/account/transactions.js"]
}, },
{ {
"matches": ["https://polytoria.com/store/**", "https://polytoria.com/places/**", "https://polytoria.com/guilds/**", "https://polytoria.com/feed/**"], "matches": ["https://polytoria.com/store/**", "https://polytoria.com/places/**", "https://polytoria.com/guilds/**", "https://polytoria.com/feed/**", "https://polytoria.co/store/**", "https://polytoria.co/places/**", "https://polytoria.co/guilds/**", "https://polytoria.co/feed/**"],
"js": ["/js/op-comments.js"] "js": ["/js/op-comments.js"]
}, },
{ {
"matches": ["https://polytoria.com/my/avatar*"], "matches": ["https://polytoria.com/my/avatar*", "https://polytoria.co/my/avatar*"],
"js": ["/js/account/avatar-sandbox2.js"] "js": ["/js/account/avatar-sandbox-rewrite.js"]
}, },
{ {
"matches": ["https://polytoria.com/inbox*"], "matches": ["https://polytoria.com/inbox*", "https://polytoria.co/inbox*"],
"js": ["/js/account/inbox.js"] "js": ["/js/account/inbox.js"]
}, },
{ {
"matches": ["https://polytoria.com/guilds/**"], "matches": ["https://polytoria.com/guilds/**", "https://polytoria.co/guilds/**"],
"js": ["/js/guilds.js"] "js": ["/js/guilds.js"]
}, },
{ {
"matches": ["https://polytoria.com/store/**", "https://polytoria.com/models/**"], "matches": ["https://polytoria.com/store/**", "https://polytoria.com/models/**", "https://polytoria.co/store/**", "https://polytoria.co/models/**"],
"js": ["/js/library-download.js"] "js": ["/js/library-download.js"]
}, },
{ {
"matches": ["https://polytoria.com/places/**", "https://polytoria.com/u/**"], "matches": ["https://polytoria.com/places/**", "https://polytoria.com/u/**", "https://polytoria.co/places/**", "https://polytoria.co/u/**"],
"js": ["the-great-divide.js"] "js": ["the-great-divide.js"]
} }
], ],
@ -127,16 +127,16 @@
"service_worker": "/js/background.js", "service_worker": "/js/background.js",
"type": "module" "type": "module"
}, },
"host_permissions": ["https://*.polytoria.com/*"], "host_permissions": ["https://*.polytoria.com/*", "https://*.polytoria.co/*"],
"web_accessible_resources": [ "web_accessible_resources": [
{ {
"resources": ["resources/*"], "resources": ["resources/*"],
"matches": ["https://polytoria.com/*"] "matches": ["https://polytoria.com/*", "https://polytoria.co/*"]
}, },
{ {
"resources": ["settings.html", "settings.js"], "resources": ["settings.html", "settings.js"],
"matches": ["https://polytoria.com/*"] "matches": ["https://polytoria.com/*", "https://polytoria.co/*"]
} }
], ],
"short_name": "Poly+", "short_name": "Poly+",