fixed item wishlist and copy asset id context menu item
This commit is contained in:
parent
121676bda8
commit
63b55d9883
5 changed files with 26 additions and 37 deletions
|
|
@ -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">
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -219,12 +214,3 @@ function CopyAvatarHash(hash) {
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
@ -114,9 +114,7 @@ let Theme = ``;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Settings.HideUserAds.Enabled === true) {
|
if (Settings.HideUserAds.Enabled === true) {
|
||||||
console.log('enabled')
|
|
||||||
if (Settings.HideUserAds.Banners === true) {
|
if (Settings.HideUserAds.Banners === true) {
|
||||||
console.log('banner')
|
|
||||||
Theme += `
|
Theme += `
|
||||||
div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
|
div[style^="max-width: 728px;"]:has(a[href^="/ads"]) {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
@ -125,7 +123,6 @@ let Theme = ``;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.HideUserAds.Rectangles === true) {
|
if (Settings.HideUserAds.Rectangles === true) {
|
||||||
console.log('rect')
|
|
||||||
Theme += `
|
Theme += `
|
||||||
div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
|
div[style^="max-width: 300px;"]:has(a[href^="/ads"]) {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
||||||
|
|
@ -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"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
}))
|
}))
|
||||||
Reference in a new issue