From 63b55d9883bb0a3aa9872c93425430fb72ca5fca Mon Sep 17 00:00:00 2001 From: Index Date: Mon, 27 May 2024 18:55:00 -0500 Subject: [PATCH] fixed item wishlist and copy asset id context menu item --- js/account/inventory.js | 11 +++++++--- js/background.js | 42 +++++++++++++------------------------ js/sitewide.js | 3 --- manifest.json | 4 ++-- resources/getUserDetails.js | 3 ++- 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/js/account/inventory.js b/js/account/inventory.js index 58bf9a8..80b6509 100755 --- a/js/account/inventory.js +++ b/js/account/inventory.js @@ -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 = ` - + Item Wishlist @@ -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 = ` diff --git a/js/background.js b/js/background.js index 2d079c7..f6b964b 100755 --- a/js/background.js +++ b/js/background.js @@ -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 @@ -218,13 +213,4 @@ function CopyAvatarHash(hash) { .catch(() => { 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) } \ No newline at end of file diff --git a/js/sitewide.js b/js/sitewide.js index e4a1b86..263e7be 100755 --- a/js/sitewide.js +++ b/js/sitewide.js @@ -114,9 +114,7 @@ let Theme = ``; }); if (Settings.HideUserAds.Enabled === true) { - console.log('enabled') if (Settings.HideUserAds.Banners === true) { - console.log('banner') Theme += ` div[style^="max-width: 728px;"]:has(a[href^="/ads"]) { display: none; @@ -125,7 +123,6 @@ let Theme = ``; } if (Settings.HideUserAds.Rectangles === true) { - console.log('rect') Theme += ` div[style^="max-width: 300px;"]:has(a[href^="/ads"]) { display: none; diff --git a/manifest.json b/manifest.json index e91570d..b04beab 100755 --- a/manifest.json +++ b/manifest.json @@ -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"] }, { diff --git a/resources/getUserDetails.js b/resources/getUserDetails.js index 2eb0bb7..48e8ecd 100644 --- a/resources/getUserDetails.js +++ b/resources/getUserDetails.js @@ -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] })) \ No newline at end of file