Merge branch 'indexxing:main' into main

This commit is contained in:
StarManTheGamer 2024-05-27 17:23:39 -07:00 committed by GitHub
commit e1ace9551b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 39 deletions

View file

@ -1,11 +1,15 @@
console.log('path', window.location.pathname.split('/')[3])
if (window.location.pathname.split('/')[3] === "inventory") { if (window.location.pathname.split('/')[3] === "inventory") {
const UserID = window.location.pathname.split('/')[2] const Username = window.location.pathname.split('/')[2]
if (UserID === JSON.parse(window.localStorage.getItem('p+account_info')).ID) { console.log(JSON.parse(window.localStorage.getItem('p+account_info')).Username)
if (Username === JSON.parse(window.localStorage.getItem('p+account_info')).Username) {
console.log('is user')
let Nav = document.getElementsByClassName('nav-pills')[0] let Nav = document.getElementsByClassName('nav-pills')[0]
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="/users/${UserID}/inventory/wishlist/" class="nav-link"> <a href="wishlist/" class="nav-link">
<i class="fa-regular fa-sparkles me-1"></i> <i class="fa-regular fa-sparkles me-1"></i>
<span class="pilltitle">Item Wishlist</span> <span class="pilltitle">Item Wishlist</span>
</a> </a>
@ -13,6 +17,7 @@ if (window.location.pathname.split('/')[3] === "inventory") {
Nav.appendChild(WishlistNav) Nav.appendChild(WishlistNav)
if (window.location.pathname.split('/')[4] === "wishlist") { if (window.location.pathname.split('/')[4] === "wishlist") {
console.log('aaa')
const ItemGrid = document.getElementsByClassName('itemgrid')[0] const ItemGrid = document.getElementsByClassName('itemgrid')[0]
const ItemCardContents = ` const ItemCardContents = `
<a href="/store/:ItemID" class="text-reset"> <a href="/store/:ItemID" class="text-reset">

View file

@ -69,10 +69,12 @@ function RunUpdateNotifier() {
} }
}) })
}) })
/*
chrome.action.setBadgeBackgroundColor( chrome.action.setBadgeBackgroundColor(
{color: 'red'}, {color: 'red'},
() => { /* ... */ }, () => { },
); );
*/
} }
}) })
.catch(error => {console.log(error)}) .catch(error => {console.log(error)})
@ -86,7 +88,7 @@ chrome.contextMenus.removeAll(function() {
id: 'PolyPlus-RunUpdateNotifier', id: 'PolyPlus-RunUpdateNotifier',
contexts: ['all'], contexts: ['all'],
documentUrlPatterns: [ documentUrlPatterns: [
"https://polytoria.com/my/settings/polyplus-debug", "https://polytoria.com/my/settings/polyplus#dev",
] ]
}); });
@ -102,7 +104,9 @@ chrome.contextMenus.removeAll(function() {
targetUrlPatterns: [ targetUrlPatterns: [
"https://polytoria.com/places/**", "https://polytoria.com/places/**",
"https://polytoria.com/users/**", "https://polytoria.com/users/**",
"https://polytoria.com/store/**" "https://polytoria.com/u/**",
"https://polytoria.com/store/**",
"https://polytoria.com/guilds/**",
] ]
}); });
@ -123,9 +127,14 @@ chrome.contextMenus.removeAll(function() {
}) })
// HANDLE CONTEXT MENU ITEMS // HANDLE CONTEXT MENU ITEMS
chrome.contextMenus.onClicked.addListener(function (info, tab){ chrome.contextMenus.onClicked.addListener(async function (info, tab){
if (info.menuItemId === 'PolyPlus-CopyID') { if (info.menuItemId === 'PolyPlus-CopyID') {
let ID = parseInt(info.linkUrl.split('/')[4]) console.log(info.linkUrl.split('/')[3])
let ID = info.linkUrl.split('/')[4]
if (info.linkUrl.split('/')[3] === "u") {
ID = (await (await fetch('https://api.polytoria.com/v1/users/find?username=' + info.linkUrl.split('/')[4])).json()).id
}
console.log(ID)
chrome.scripting chrome.scripting
.executeScript({ .executeScript({
target: {tabId: tab.id}, target: {tabId: tab.id},
@ -151,20 +160,6 @@ chrome.contextMenus.onClicked.addListener(function (info, tab){
} }
}); });
chrome.runtime.onMessage.addListener(function (message, sender) {
console.log('hi')
message = message.message || ''
console.log(message)
if (message === 'tooltip') {
console.log('is about tooltip')
chrome.scripting
.executeScript({
target: {tabId: sender.tab.id},
func: UpdateTooltips
})
}
});
/* /*
GREEN LOGO WHEN EXTENSION APPLIES TO CURRENT TAB PAGE, RED WHEN IT DOESN'T GREEN LOGO WHEN EXTENSION APPLIES TO CURRENT TAB PAGE, RED WHEN IT DOESN'T
COMING SOON COMING SOON
@ -218,13 +213,4 @@ function CopyAvatarHash(hash) {
.catch(() => { .catch(() => {
alert('Failure to copy avatar hash.') alert('Failure to copy avatar hash.')
}); });
}
function UpdateTooltips() {
const Script = document.createElement('script')
Script.innerHTML = `
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
`
document.body.appendChild(Script)
} }

View file

@ -113,18 +113,18 @@ let Theme = ``;
} }
}); });
if (Settings.HideUserAdsOn === true) { if (Settings.HideUserAds.Enabled === true) {
if (Settings.HideUserAdsOn.Banners === true) { if (Settings.HideUserAds.Banners === true) {
Theme += ` Theme += `
div[style^="max-width: 728px;"]:has(.text-center a[href^="/ads/"]) { div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
display: none; display: none;
} }
` `
} }
if (Settings.HideUserAdsOn.Rectangles === true) { if (Settings.HideUserAds.Rectangles === true) {
Theme += ` Theme += `
div[style^="max-width: 300px;"]:has(.text-center a[href^="/ads/"]) { div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
display: none; display: none;
} }
` `

View file

@ -43,8 +43,8 @@
}, },
{ {
"matches": ["https://polytoria.com/u/**"], "matches": ["https://polytoria.com/u/**", "https://polytoria.com/users/**"],
"js": ["/js/account/profile.js"] "js": ["/js/account/profile.js", "/js/account/inventory.js"]
}, },
{ {

View file

@ -1,4 +1,5 @@
window.localStorage.setItem('p+account_info', JSON.stringify({ window.localStorage.setItem('p+account_info', JSON.stringify({
ID: userID, ID: userID,
Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'') Username: document.querySelector('a[href^="/u"]:has(.dropdown-item):first-child').innerText.replaceAll('\n', '').replaceAll('\t', '').trim(),
Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'').split('(')[0]
})) }))