diff --git a/js/background.js b/js/background.js index 96a072f..fda2dbf 100755 --- a/js/background.js +++ b/js/background.js @@ -152,160 +152,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { } }, 5000); }) - } else if (request.action === 'greatdivide_stats') { - chrome.storage.local.get(['PolyPlus_GreatDivideStats_' + request.userID], async function(result){ - let Statistics = result['PolyPlus_GreatDivideStats_' + request.userID] - - // cache for 5 minutes - if (Statistics !== undefined && (new Date().getTime() - Statistics.requested < 300000)) { - Statistics = Statistics.data - } else { - Statistics = (await (await fetch('https://stats.silly.mom/player_stats?id=' + request.userID)).json()).results - if (Statistics !== null) { Statistics = Statistics[0] } - chrome.storage.local.set({['PolyPlus_GreatDivideStats_' + request.userID]: {data: Statistics, requested: new Date().getTime()}}, function(){}) - } - - chrome.tabs.query({ active: true, currentWindow: true }, function(tabs){ - chrome.scripting - .executeScript({ - target: {tabId: tabs[0].id}, - func: LoadStats, - args: [Statistics] - }) - }) - }) - - const LoadStats = function(stats){ - const GreatDivideCard = document.getElementById('p+greatdivide_card') - if (stats !== null) { - let KDR = (stats.Kills / stats.Deaths) - if (isNaN(KDR)) { - KDR = "N/A" - } else { - KDR = KDR.toFixed(4) - } - - GreatDivideCard.innerHTML = ` -
- - - Last Round Seen - - - ${ (stats.LastRoundSeen === 0) ? '-' : stats.LastRoundSeen } - -
-
-
- - - Kills - - - ${stats.Kills.toLocaleString()} (${stats.UniqueKills.toLocaleString()} unique) - -
-
- - - Deaths - - - ${stats.Deaths.toLocaleString()} - -
-
- - - Kill Death Ratio - - - ${KDR} - -
-
- - - Points Scored - - - ${stats.PointsScored.toLocaleString()} - -
-
- - - Cash Earned - - - ${stats.CashEarned.toLocaleString()} - -
-
- - - Flags Captured - - - ${stats.FlagsCaptured} (${stats.FlagsReturned} returned) - -
-
- - - Airdrops Collected - - - ${stats.AirdropsCollected} - -
-
-
- - - Monoliths Destroyed - - - ${stats.ObelisksDestroyed} - -
-
- - - Blocks Placed - - - ${stats.BlocksPlaced} (${stats.BlocksDestroyed} destroyed) - -
-
- - - Headshots - - - ${stats.Headshots} - -
- ` - - const Script = document.createElement('script'); - Script.setAttribute('type', 'text/javascript'); - Script.setAttribute('src', chrome.runtime.getURL('resources/registerTooltips.js')); - Script.addEventListener('load', function () { - Script.remove(); - }); - document.body.appendChild(Script); - } else { - GreatDivideCard.classList.add('text-center', 'py-5') - GreatDivideCard.innerHTML = ` -

-
Not Drafted
-

This user hasn't participated in The Great Divide.

- ` - } - } - return true } }); diff --git a/manifest.json b/manifest.json index eeed5bc..6063e5a 100644 --- a/manifest.json +++ b/manifest.json @@ -121,11 +121,6 @@ { "matches": ["https://polytoria.com/games/*", "https://polytoria.com/shop/*", "https://polytoria.com/my/referrals", "https://polytoria.com/create/?t=*", "https://polytoria.com/user/*", "https://polytoria.com/library/*"], "js": ["/js/site-redirects.js"] - }, - - { - "matches": ["https://polytoria.com/places/**", "https://polytoria.com/u/**"], - "js": ["the-great-divide.js"] } ], "background": { diff --git a/the-great-divide.js b/the-great-divide.js deleted file mode 100644 index 4075398..0000000 --- a/the-great-divide.js +++ /dev/null @@ -1,112 +0,0 @@ -let EventOngoing = true; -let Team; -let HasTeam = true; - -const PlaceAllowlist = [ - '9656', - '9757' -]; - -(async () => { - Utilities = await import(chrome.runtime.getURL('resources/utils.js')) - .default - - chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { - Settings = result.PolyPlus_Settings || {}; - - if (Settings.TheGreatDivide.Enabled !== true) { - return - } - - Team = document.querySelector('#user-avatar-card a[href^="/event/"]') - if (Team === null) { - HasTeam = false - } else { - if (Team.getElementsByClassName('userlink-team-phantoms').length > 0) { - Team = "phantoms" - } else if (Team.getElementsByClassName('userlink-team-cobras').length > 0) { - Team = "cobras" - } - } - if (new Date().getMonth().toString()+new Date().getDate().toString() >= 714) { EventOngoing = false } - - if (Settings.TheGreatDivide.UnbalancedIndicatorOn === true && window.location.pathname.split('/')[1] === 'places' && PlaceAllowlist.indexOf(window.location.pathname.split('/')[2]) !== -1) { - UnbalancedServerMarkers() - } - - if (Settings.TheGreatDivide.UserStatsOn === true && window.location.pathname.split('/')[1] === 'u') { - if (HasTeam === true) { - UserStatsTab() - } else { - if (EventOngoing === true) { - UserStatsTab() - } - } - } - }) - - async function UnbalancedServerMarkers() { - const Team = (await (await fetch('https://api.polytoria.com/v1/users/' + JSON.parse(window.localStorage.getItem('p+account_info')).ID + '/greatdivide')).json()).team - if (Team !== undefined) { - const Servers = Array.from(document.getElementById('servers-tabpane').children) - - Servers.forEach(server => { - const TeamCounts = { - phantoms: server.getElementsByClassName('border-phantoms').length, - cobras: server.getElementsByClassName('border-cobras').length - } - - let Enemy = "cobras" - if (Team === "cobras") { Enemy = "phantoms" } - - if (new URLSearchParams(window.location.search).has('forceServerUnbalance')) { - TeamCounts[Enemy] = 1000 - } - - if (TeamCounts[Team] < TeamCounts[Enemy]) { - const UnbalancedText = document.createElement('p') - UnbalancedText.classList = 'mb-2' - UnbalancedText.style.fontSize = '0.7rem' - UnbalancedText.style.color = 'orange' - UnbalancedText.innerHTML = `*Potentially Unbalanced ` - - const ServerInfoColumn = server.getElementsByClassName('col-3')[0] - ServerInfoColumn.children[0].style.marginBottom = '0px' - ServerInfoColumn.insertBefore(UnbalancedText, ServerInfoColumn.children[1]) - - Utilities.InjectResource("registerTooltips") - } - }) - } - } - - async function UserStatsTab() { - const EventSection = document.createElement('div') - EventSection.innerHTML = ` -
-
- - GREATEST DIVISION - -
-
-
- -
-
- ` - document.getElementsByClassName('user-right')[0].appendChild(EventSection) - - const EventCard = document.getElementById('p+greatdivide_card') - EventCard.innerHTML = ` - - Loading... - - - ` - await chrome.runtime.sendMessage({ - action: "greatdivide_stats", - userID: document.querySelector('.dropdown-item.text-danger[href^="/report"]').getAttribute('href').split('?')[0].split('/')[3] - }); - } -})(); \ No newline at end of file