irl price on resellers and no more pagination on item wishlist and collectibles
This commit is contained in:
parent
9457437ba6
commit
deeaba05b2
6 changed files with 268 additions and 82 deletions
|
|
@ -222,7 +222,6 @@ async function UpdateAvatar() {
|
|||
if (ItemCache[x] === undefined) {
|
||||
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
|
||||
ItemCache[x] = {
|
||||
/*
|
||||
type: ItemDetails.type,
|
||||
name: ItemDetails.name,
|
||||
price: ItemDetails.price,
|
||||
|
|
@ -231,7 +230,6 @@ async function UpdateAvatar() {
|
|||
id: ItemDetails.creator.id
|
||||
},
|
||||
thumbnail: ItemDetails.thumbnail,
|
||||
*/
|
||||
asset: undefined
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
/*
|
||||
Proper pagination will be added in v1.2.3
|
||||
*/
|
||||
|
||||
Username = window.location.pathname.split('/')[2];
|
||||
let UserID;
|
||||
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;
|
||||
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
|
||||
|
||||
const Nav = document.getElementsByClassName('nav-pills')[0];
|
||||
|
||||
if (Settings.ItemWishlistOn
|
||||
&& Username === JSON.parse(window.localStorage.getItem('p+account_info')).Username
|
||||
&& window.location.pathname.split('/')[4] === 'wishlist'
|
||||
) {
|
||||
if (Settings.ItemWishlistOn && Username === JSON.parse(window.localStorage.getItem('p+account_info')).Username) {
|
||||
let WishlistNav = document.createElement('li');
|
||||
WishlistNav.classList.add('nav-item');
|
||||
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>
|
||||
<span class="pilltitle">Item Wishlist</span>
|
||||
</a>
|
||||
|
|
@ -45,7 +49,7 @@ if (window.location.pathname.split('/')[3] === 'inventory') {
|
|||
let CollectibleNav = document.createElement('li');
|
||||
CollectibleNav.classList.add('nav-item');
|
||||
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>
|
||||
<span class="pilltitle">Collectibles</span>
|
||||
</a>
|
||||
|
|
@ -70,6 +74,9 @@ if (window.location.pathname.split('/')[3] === 'inventory') {
|
|||
})();
|
||||
}
|
||||
|
||||
/*
|
||||
Item Wishlist will be rewritten in v1.2.3
|
||||
*/
|
||||
function ItemWishlist() {
|
||||
const ItemGrid = document.getElementsByClassName('itemgrid')[0];
|
||||
const ItemCardContents = `
|
||||
|
|
@ -91,6 +98,7 @@ function ItemWishlist() {
|
|||
`;
|
||||
|
||||
ItemGrid.innerHTML = ''
|
||||
document.getElementsByClassName('pagination')[0].remove()
|
||||
const Search = document.createElement('div');
|
||||
Search.classList = 'row';
|
||||
Search.innerHTML = `
|
||||
|
|
@ -111,8 +119,8 @@ function ItemWishlist() {
|
|||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="polyplus-itemwish-isLimited">
|
||||
<label class="form-check-label" for="polyplus-itemwish-isLimited">
|
||||
Is Limited?
|
||||
<span class="text-muted" style="font-size: 0.65rem; display: block;">Items that are limited</span>
|
||||
Is Collectible?
|
||||
<span class="text-muted" style="font-size: 0.65rem; display: block;">Items that are collectible</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -156,7 +164,7 @@ function ItemWishlist() {
|
|||
Wishlist.forEach((element) => {
|
||||
let NewItemCard = document.createElement('div');
|
||||
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((data) => {
|
||||
NewItemCard.innerHTML = ItemCardContents.replace(':ItemID', data.id)
|
||||
|
|
@ -200,9 +208,8 @@ function ItemWishlist() {
|
|||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const Update = function(type, query, isLimited, isAvailable) {
|
||||
const Update = function(type, query, isLimited, isAvailable) {
|
||||
let ItemGrid = document.getElementsByClassName('itemgrid')[0];
|
||||
let BrickBalance = parseInt(JSON.parse(window.localStorage.getItem('p+account_info')).Bricks);
|
||||
query = query.toLowerCase();
|
||||
|
|
@ -240,10 +247,12 @@ const Update = function(type, query, isLimited, isAvailable) {
|
|||
Results[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function CollectibleCategory() {
|
||||
ItemGrid.innerHTML = ''
|
||||
document.getElementsByClassName('pagination')[0].remove()
|
||||
const CollectibleItemTypes = [
|
||||
"hat",
|
||||
"face",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ let Utilities;
|
|||
|
||||
if (Username) {
|
||||
(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 = Utilities.default;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var Utilities;
|
|||
Utilities.InjectResource('registerTooltips');
|
||||
}
|
||||
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
|
||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||
IRLPrice();
|
||||
}
|
||||
|
||||
|
|
@ -96,9 +96,7 @@ chrome.storage.onChanged.addListener(function (changes, namespace) {
|
|||
|
||||
async function IRLPrice() {
|
||||
const Price = PurchaseBtn.getAttribute('data-price');
|
||||
if (Price === null || Price === '0') {
|
||||
return;
|
||||
}
|
||||
if (Price !== null && Price !== '0') {
|
||||
const Span = document.createElement('span');
|
||||
Span.classList = 'text-muted polyplus-own-tag';
|
||||
Span.style.fontSize = '0.7rem';
|
||||
|
|
@ -106,6 +104,29 @@ async function IRLPrice() {
|
|||
const IRLResult = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrency.Currency);
|
||||
Span.innerText = '($' + IRLResult.result + ' ' + IRLResult.display + ')';
|
||||
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() {
|
||||
|
|
|
|||
158
manifest-old.json
Normal file
158
manifest-old.json
Normal 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"
|
||||
}
|
||||
}
|
||||
|
|
@ -9,117 +9,117 @@
|
|||
"permissions": ["storage", "contextMenus", "scripting", "alarms", "notifications"],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://polytoria.com/*"],
|
||||
"matches": ["https://polytoria.com/*", "https://polytoria.co/*"],
|
||||
"js": ["/js/sitewide.js", "/js/membership-themes.js"],
|
||||
"css": ["/css/specific.css"],
|
||||
"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"],
|
||||
"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"],
|
||||
"run_at": "document_idle"
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/places/**"],
|
||||
"matches": ["https://polytoria.com/places/**", "https://polytoria.co/places/**"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/forum/post/**"],
|
||||
"matches": ["https://polytoria.com/forum/post/**", "https://polytoria.co/forum/post/**"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/store/**"],
|
||||
"matches": ["https://polytoria.com/store/**", "https://polytoria.co/store/**"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/trade/sent/*"],
|
||||
"matches": ["https://polytoria.com/trade/sent/*", "https://polytoria.co/trade/sent/*"],
|
||||
"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"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/my/avatar*"],
|
||||
"js": ["/js/account/avatar-sandbox2.js"]
|
||||
"matches": ["https://polytoria.com/my/avatar*", "https://polytoria.co/my/avatar*"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/guilds/**"],
|
||||
"matches": ["https://polytoria.com/guilds/**", "https://polytoria.co/guilds/**"],
|
||||
"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"]
|
||||
},
|
||||
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
],
|
||||
|
|
@ -127,16 +127,16 @@
|
|||
"service_worker": "/js/background.js",
|
||||
"type": "module"
|
||||
},
|
||||
"host_permissions": ["https://*.polytoria.com/*"],
|
||||
"host_permissions": ["https://*.polytoria.com/*", "https://*.polytoria.co/*"],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["resources/*"],
|
||||
"matches": ["https://polytoria.com/*"]
|
||||
"matches": ["https://polytoria.com/*", "https://polytoria.co/*"]
|
||||
},
|
||||
|
||||
{
|
||||
"resources": ["settings.html", "settings.js"],
|
||||
"matches": ["https://polytoria.com/*"]
|
||||
"matches": ["https://polytoria.com/*", "https://polytoria.co/*"]
|
||||
}
|
||||
],
|
||||
"short_name": "Poly+",
|
||||
|
|
|
|||
Reference in a new issue