+
+ {createSkillLevelElement({
+ level: 1,
+ currentLevel,
+ eloFrom: 1,
+ eloTo: 800,
+ width: 40
+ })}
+ {createSkillLevelElement({
+ level: 2,
+ currentLevel,
+ eloFrom: 801,
+ eloTo: 950
+ })}
+ {createSkillLevelElement({
+ level: 3,
+ currentLevel,
+ eloFrom: 951,
+ eloTo: 1100
+ })}
+ {createSkillLevelElement({
+ level: 4,
+ currentLevel,
+ eloFrom: 1101,
+ eloTo: 1250
+ })}
+ {createSkillLevelElement({
+ level: 5,
+ currentLevel,
+ eloFrom: 1251,
+ eloTo: 1400
+ })}
+ {createSkillLevelElement({
+ level: 6,
+ currentLevel,
+ eloFrom: 1401,
+ eloTo: 1550
+ })}
+ {createSkillLevelElement({
+ level: 7,
+ currentLevel,
+ eloFrom: 1551,
+ eloTo: 1700
+ })}
+ {createSkillLevelElement({
+ level: 8,
+ currentLevel,
+ eloFrom: 1701,
+ eloTo: 1850
+ })}
+ {createSkillLevelElement({
+ level: 9,
+ currentLevel,
+ eloFrom: 1851,
+ eloTo: 2000
+ })}
-
+
100 ? '#f50' : '#323737'
+ width: progressWidth > 100 ? '100%' : `${progressWidth}%`,
+ height: '100%',
+ background: '#f50'
}}
/>
- {skillLevelElement({
- level: 10,
- currentLevel,
- eloFrom: 2001,
- eloTo: '∞',
- width: 100,
- borderRight: false
- })}
+
+ {createSkillLevelElement({
+ level: 10,
+ currentLevel,
+ eloFrom: 2001,
+ eloTo: '∞',
+ width: 100,
+ borderRight: false
+ })}
+
100 ? '#f50' : '#323737'
+ }}
+ />
+
-
+
)
- profileElement.prepend(
)
- profileElement.prepend(levelProgressElement)
+ const mainStatsElement = select('.sc-jpGZec', playerProfileElement)
+
+ playerProfileElement.insertBefore(levelProgressElement, mainStatsElement)
+
+ playerProfileElement.insertBefore(createHrElement(), mainStatsElement)
}
diff --git a/src/content/features/add-player-profile-matches-demo.js b/src/content/features/add-player-profile-matches-demo.js
new file mode 100644
index 00000000..4c848c69
--- /dev/null
+++ b/src/content/features/add-player-profile-matches-demo.js
@@ -0,0 +1,112 @@
+/** @jsx h */
+import { h } from 'dom-chef'
+import select from 'select-dom'
+import get from 'lodash/get'
+import {
+ hasFeatureAttribute,
+ setFeatureAttribute
+} from '../helpers/dom-element'
+import {
+ getQuickMatch,
+ getMatch,
+ getPlayer,
+ getPlayerMatches
+} from '../helpers/faceit-api'
+import {
+ getPlayerProfileNickname,
+ getPlayerProfileStatsGame
+} from '../helpers/player-profile'
+import createButton from '../components/button'
+
+const FEATURE_ATTRIBUTE = 'matches-demo'
+
+export default async parentElement => {
+ const playerProfileParasiteElement = select(
+ 'parasite-player-profile-content',
+ parentElement
+ )
+
+ if (!playerProfileParasiteElement) {
+ return
+ }
+
+ const playerProfileElement = select(
+ '.sc-egCXko',
+ playerProfileParasiteElement.shadowRoot
+ )
+
+ const matchElements = select.all('.sc-dDxMOP', playerProfileElement)
+
+ matchElements.shift()
+
+ if (
+ !playerProfileElement ||
+ playerProfileElement.children.length < 10 ||
+ matchElements.length === 0 ||
+ hasFeatureAttribute(FEATURE_ATTRIBUTE, playerProfileElement)
+ ) {
+ return
+ }
+ setFeatureAttribute(FEATURE_ATTRIBUTE, playerProfileElement)
+
+ const matchElementsHead = select('.sc-dDxMOP', playerProfileElement)
+
+ matchElementsHead.append(
+
+ Demo
+ |
+ )
+
+ const nickname = getPlayerProfileNickname()
+ const player = await getPlayer(nickname)
+ const game = getPlayerProfileStatsGame()
+ const matches = await getPlayerMatches(player.guid, game)
+
+ matchElements.forEach(async (matchElement, index) => {
+ const matchId = matches[index].matchId
+
+ if (!matchId) {
+ return
+ }
+
+ const downloadButtonElement = (
+
+ {createButton({
+ text: 'Watch Demo',
+ onClick: async e => {
+ e.stopPropagation()
+ const match =
+ (await getQuickMatch(matchId)) || (await getMatch(matchId))
+ const demoUrl =
+ get(match, 'externalMatches[0].stats.demoFileUrl') ||
+ match.demoUrl ||
+ match.demoUrLs[0]
+
+ if (demoUrl) {
+ window.open(demoUrl)
+ }
+ }
+ })}
+ |
+ )
+
+ matchElement.insertBefore(
+ downloadButtonElement,
+ matchElement.children[matchElement.children.length - 1]
+ )
+ })
+}
diff --git a/src/content/features/add-profile-matches-elo-points.js b/src/content/features/add-player-profile-matches-elo.js
similarity index 72%
rename from src/content/features/add-profile-matches-elo-points.js
rename to src/content/features/add-player-profile-matches-elo.js
index 9b901f1f..6ec580f8 100644
--- a/src/content/features/add-profile-matches-elo-points.js
+++ b/src/content/features/add-player-profile-matches-elo.js
@@ -13,30 +13,36 @@ import {
} from '../helpers/dom-element'
import { getIsFreeMember } from '../helpers/membership'
-const FEATURE_ATTRIBUTE = 'elo-points'
+const FEATURE_ATTRIBUTE = 'matches-elo'
export default async parentElement => {
- const matchHistoryElement = select(
- 'div.js-match-history-stats',
+ const playerProfileParasiteElement = select(
+ 'parasite-player-profile-content',
parentElement
)
- const matchElements = select.all(
- 'tbody > tr.match-history-stats__row',
- matchHistoryElement
+
+ if (!playerProfileParasiteElement) {
+ return
+ }
+
+ const playerProfileElement = select(
+ '.sc-egCXko',
+ playerProfileParasiteElement.shadowRoot
)
+ const matchElements = select.all('.sc-dDxMOP', playerProfileElement)
+
+ matchElements.shift()
+
if (
- !matchHistoryElement ||
+ !playerProfileElement ||
+ playerProfileElement.children.length < 10 ||
matchElements.length === 0 ||
- hasFeatureAttribute(FEATURE_ATTRIBUTE, matchHistoryElement)
+ hasFeatureAttribute(FEATURE_ATTRIBUTE, playerProfileElement)
) {
return
}
- setFeatureAttribute(FEATURE_ATTRIBUTE, matchHistoryElement)
-
- if (matchElements.length === 0) {
- return
- }
+ setFeatureAttribute(FEATURE_ATTRIBUTE, playerProfileElement)
const nickname = getPlayerProfileNickname()
const game = getPlayerProfileStatsGame()
@@ -86,7 +92,13 @@ export default async parentElement => {
}
const newEloElement = (
-
+
New Elo: {newElo}
)
diff --git a/src/content/index.js b/src/content/index.js
index 05008fba..2e99b7be 100755
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -18,7 +18,7 @@ import clickMatchRoomConnectToServer from './features/click-match-room-connect-t
import addHeaderLevelProgress from './features/add-header-level-progress'
import hideMatchRoomPlayerControls from './features/hide-match-room-player-controls'
import hideFaceitClientHasLandedBanner from './features/hide-faceit-client-has-landed-banner'
-import addProfileMatchesEloPoints from './features/add-profile-matches-elo-points'
+import addPlayerProfileMatchesElo from './features/add-player-profile-matches-elo'
import clickMatchRoomVetoLocations from './features/click-match-room-veto-locations'
import clickMatchRoomVetoMaps from './features/click-match-room-veto-maps'
import clickModalMatchRoomCaptainOk from './features/click-modal-match-room-captain-ok'
@@ -27,7 +27,7 @@ import addMatchRoomPickPlayerStats from './features/add-match-room-pick-player-s
import addMatchRoomPickPlayerElos from './features/add-match-room-pick-player-elos'
import addMatchRoomPickPlayerFlags from './features/add-match-room-pick-player-flags'
import addPlayerControlsReportFix from './features/add-match-room-player-controls-report-fix'
-import addPlayerProfileDownloadDemo from './features/add-player-profile-download-demo'
+import addPlayerProfileMatchesDemo from './features/add-player-profile-matches-demo'
import addPlayerProfileExtendedStats from './features/add-player-profile-extended-stats'
import addPlayerProfileBadge from './features/add-player-profile-badge'
import clickModalClose from './features/click-modal-close'
@@ -48,8 +48,9 @@ function observeBody() {
return
}
- const observer = new MutationObserver(() => {
+ const observer = new MutationObserver(mutationList => {
const modalElement = select('.modal-dialog')
+
if (modalElement) {
if (modals.isInviteToParty(modalElement)) {
runFeatureIf(
@@ -97,8 +98,8 @@ function observeBody() {
addPlayerProfileLevelProgress,
modalElement
)
- addPlayerProfileDownloadDemo(modalElement)
- addProfileMatchesEloPoints(modalElement)
+ addPlayerProfileMatchesDemo(modalElement)
+ addPlayerProfileMatchesElo(modalElement)
addPlayerProfileExtendedStats(modalElement)
}
}
@@ -171,8 +172,8 @@ function observeBody() {
addPlayerProfileLevelProgress,
mainContentElement
)
- addProfileMatchesEloPoints(mainContentElement)
- addPlayerProfileDownloadDemo(mainContentElement)
+ addPlayerProfileMatchesElo(mainContentElement)
+ addPlayerProfileMatchesDemo(mainContentElement)
addPlayerProfileExtendedStats(mainContentElement)
}
} else if (pages.isTeamsOverview()) {
@@ -183,6 +184,17 @@ function observeBody() {
)
}
}
+
+ for (const mutation of mutationList) {
+ for (const addedNode of mutation.addedNodes) {
+ if (addedNode.shadowRoot) {
+ observer.observe(addedNode.shadowRoot, {
+ childList: true,
+ subtree: true
+ })
+ }
+ }
+ }
})
observer.observe(document.body, { childList: true, subtree: true })