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 = ` -
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 = ` - -