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") {
const UserID = window.location.pathname.split('/')[2]
if (UserID === JSON.parse(window.localStorage.getItem('p+account_info')).ID) {
const Username = window.location.pathname.split('/')[2]
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 WishlistNav = document.createElement('li')
WishlistNav.classList.add('nav-item')
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>
<span class="pilltitle">Item Wishlist</span>
</a>
@ -13,6 +17,7 @@ if (window.location.pathname.split('/')[3] === "inventory") {
Nav.appendChild(WishlistNav)
if (window.location.pathname.split('/')[4] === "wishlist") {
console.log('aaa')
const ItemGrid = document.getElementsByClassName('itemgrid')[0]
const ItemCardContents = `
<a href="/store/:ItemID" class="text-reset">

View file

@ -69,10 +69,12 @@ function RunUpdateNotifier() {
}
})
})
/*
chrome.action.setBadgeBackgroundColor(
{color: 'red'},
() => { /* ... */ },
() => { },
);
*/
}
})
.catch(error => {console.log(error)})
@ -86,7 +88,7 @@ chrome.contextMenus.removeAll(function() {
id: 'PolyPlus-RunUpdateNotifier',
contexts: ['all'],
documentUrlPatterns: [
"https://polytoria.com/my/settings/polyplus-debug",
"https://polytoria.com/my/settings/polyplus#dev",
]
});
@ -102,7 +104,9 @@ chrome.contextMenus.removeAll(function() {
targetUrlPatterns: [
"https://polytoria.com/places/**",
"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
chrome.contextMenus.onClicked.addListener(function (info, tab){
chrome.contextMenus.onClicked.addListener(async function (info, tab){
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
.executeScript({
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
COMING SOON
@ -219,12 +214,3 @@ function CopyAvatarHash(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.HideUserAdsOn.Banners === true) {
if (Settings.HideUserAds.Enabled === true) {
if (Settings.HideUserAds.Banners === true) {
Theme += `
div[style^="max-width: 728px;"]:has(.text-center a[href^="/ads/"]) {
div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
display: none;
}
`
}
if (Settings.HideUserAdsOn.Rectangles === true) {
if (Settings.HideUserAds.Rectangles === true) {
Theme += `
div[style^="max-width: 300px;"]:has(.text-center a[href^="/ads/"]) {
div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
display: none;
}
`

View file

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

View file

@ -1,4 +1,5 @@
window.localStorage.setItem('p+account_info', JSON.stringify({
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]
}))