Skip to content

Commit

Permalink
Adding modules to show clubmates and script Patreon supporters on lea…
Browse files Browse the repository at this point in the history
…derboards (league, contests, season, pantheon, pov, pog)
  • Loading branch information
Numbers committed Jan 21, 2023
1 parent 1e51b7d commit 02a75a2
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 119 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
1.29.0: Adding modules to show clubmates and script Patreon supporters on leaderboards (league, contests, season, pantheon, pov, pog)
1.28.24: Annotating Season, Pantheon and Po* leaderboards with player IDs (enabler for future modules)
1.28.23: Enabling pantheon script features on CxH
1.28.22: Fixing some missing icons, fixing pantheon leaderboard now that it's the same as Po*, improving simulator logging, fixing monthly card text tweak for the new icons
Expand Down
88 changes: 77 additions & 11 deletions dist/hh-plus-plus.dev.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/hh-plus-plus.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Hentai Heroes++ BDSM version
// @description Adding things here and there in the Hentai Heroes game. Also supports HHCore-based games such as GH and CxH.
// @version 1.28.24
// @version 1.29.0
// @match https://*.hentaiheroes.com/*
// @match https://nutaku.haremheroes.com/*
// @match https://*.gayharem.com/*
Expand Down
198 changes: 99 additions & 99 deletions dist/hh-plus-plus.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hh-plus-plus",
"version": "1.28.24",
"version": "1.29.0",
"description": "Adding things here and there in the Hentai Heroes game. Also supports HHCore-based games such as GH and CxH.",
"private": "true",
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions src/common/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let isNutakuKobans
let cdnHost
let girlDictionary
let teamsDictionary
let platform

const deferred = []

Expand Down Expand Up @@ -94,6 +95,22 @@ class Helpers {
}
}

static getPlatform () {
if (!platform) {
const host = Helpers.getHost()
if (host.includes('nutaku')) {
platform = 'nutaku'
} else if (host.includes('erogames')) {
platform = 'erogames'
} else if (host.includes('thrixxx')) {
platform = 'thrixxx'
} else {
platform = '.com'
}
}
return platform
}

static isNutakuKobans () {
if (typeof isNutakuKobans === 'undefined') {
isNutakuKobans = HH_UNIVERSE === 'nutaku'
Expand Down
2 changes: 1 addition & 1 deletion src/common/TableAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TableAnnotation {
Helpers.doWhenSelectorAvailable(`${selector} .leaderboard_row`, () => {
const $leaderboardList = $(selector)

$leaderboardList.find('.leaderboard_row:not(.build-at-bottom)').each((i, el) => {
$leaderboardList.find('.leaderboard_row:not(.build-at-bottom):not(.script-season-leaderboard-fix)').each((i, el) => {
$(el).attr('sorting_id', leaderboard[i].id_member)
})

Expand Down
5 changes: 5 additions & 0 deletions src/i18n/labels/De.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const config = {
eventEndIndicators: 'Anzeige für Eventende auf dem Startbildschirm',
haremTeamsFilter: 'Teamfilter für Harem',
upgradeQuickNav: 'Schnellnavigation auf der Upgrade-Seite',
leaderboardClubmateIndicators: 'Club-Mitglieder auf Ranglisten hervorheben',
}
export const stConfig = {
missionsBackground: 'Missionshintergrund ändern',
Expand Down Expand Up @@ -290,3 +291,7 @@ export const haremTeamsFilter = {
team: 'Team',
visitTeams: 'Besuche zuerst die <a href="../teams.html">Teams</a>.',
}

export const leaderboardClubmateIndicators = {
clubmate: 'Club-Mitglieder',
}
5 changes: 5 additions & 0 deletions src/i18n/labels/En.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const config = {
eventEndIndicators: 'Event ending indicators on home screen',
haremTeamsFilter: 'Harem teams filter',
upgradeQuickNav: 'Upgrade page quick navigation',
leaderboardClubmateIndicators: 'Highlight clubmates on leaderboards',
}
export const stConfig = {
missionsBackground: 'Change missions background',
Expand Down Expand Up @@ -358,3 +359,7 @@ export const haremTeamsFilter = {
team: 'Team',
visitTeams: 'Visit <a href="../teams.html">Teams</a> first.',
}

export const leaderboardClubmateIndicators = {
clubmate: 'Clubmate',
}
5 changes: 5 additions & 0 deletions src/i18n/labels/Es.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const config = {
eventEndIndicators: 'Indicadores de finalización de evento en la pantalla de inicio',
haremTeamsFilter: 'Filtro de equipos de harén',
upgradeQuickNav: 'Navegación rápida en la página de actualización',
leaderboardClubmateIndicators: 'Destacar a los compañeros de club en las tablas de clasificación',
}
export const stConfig = {
missionsBackground: 'Cambiar el fondo de las misiones',
Expand Down Expand Up @@ -313,3 +314,7 @@ export const haremTeamsFilter = {
team: 'Equipo',
visitTeams: 'Visita el <a href="../teams.html">Equipos</a> primero.'
}

export const leaderboardClubmateIndicators = {
clubmate: 'Compañero de club',
}
5 changes: 5 additions & 0 deletions src/i18n/labels/Fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const config = {
eventEndIndicators: 'Indicateurs de fin d\'évènement sur la page d\'accueil',
haremTeamsFilter: 'Filtre d\'équipes dans le harem',
upgradeQuickNav: 'Navigation rapide sur la page d\'amélioration',
leaderboardClubmateIndicators: 'Surligner les coéquipiers dans les classements',
}
export const stConfig = {
missionsBackground: 'Change l\'arrière-plan des missions',
Expand Down Expand Up @@ -320,3 +321,7 @@ export const haremTeamsFilter = {
team: 'Équipe',
visitTeams: 'Visiter d\'abord <a href="../teams.html">l\'équipe</a>.',
}

export const leaderboardClubmateIndicators = {
clubmate: 'Coéquipier',
}
5 changes: 5 additions & 0 deletions src/i18n/labels/It.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const config = {
eventEndIndicators: 'Mostra per la fine dell\'evento nella schermata iniziale',
haremTeamsFilter: 'Filtro squadra per harem',
upgradeQuickNav: 'Navigazione rapida sulla pagina di aggiornamento',
leaderboardClubmateIndicators: 'Evidenziare i soci del club nelle classifiche',
}
export const stConfig = {
missionsBackground: 'Cambiare lo sfondo delle missioni',
Expand Down Expand Up @@ -319,3 +320,7 @@ export const haremTeamsFilter = {
team: 'Squadra',
visitTeams: 'Visita le <a href="../teams.html">Squadre</a> prima.'
}

export const leaderboardClubmateIndicators = {
clubmate: 'Soci del club',
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Helpers from './common/Helpers'
import TableAnnotation from './common/TableAnnotation'
import Config from './config'
import * as modules from './modules'
import LeaderboardSupportersIndicatorsModule from './modules/LeaderboardSupportersIndicatorsModule'

const runScript = () => {
const config = new Config()
Expand All @@ -36,6 +37,8 @@ const runScript = () => {

TableAnnotation.run()

new LeaderboardSupportersIndicatorsModule().run()

// configurable modules

// core
Expand Down
63 changes: 63 additions & 0 deletions src/modules/LeaderboardClubmateIndicatorsModule/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import CoreModule from '../CoreModule'
import Helpers from '../../common/Helpers'
import I18n from '../../i18n'

import styles from './styles.lazy.scss'
import { lsKeys } from '../../common/Constants'

const MODULE_KEY = 'leaderboardClubmateIndicators'

class LeaderboardClubmateIndicatorsModule extends CoreModule {
constructor () {
super({
baseKey: MODULE_KEY,
label: I18n.getModuleLabel('config', MODULE_KEY),
default: true
})
this.label = I18n.getModuleLabel.bind(this, MODULE_KEY)
}

shouldRun () {
return ['activities', 'tower-of-fame', 'pantheon', 'season.html', 'path-of-valor', 'path-of-glory'].some(page => Helpers.isCurrentPage(page))
}

run () {
if (this.hasRun || !this.shouldRun()) {return}

styles.use()

Helpers.defer(() => {
if (['activities', 'tower-of-fame'].some(page => Helpers.isCurrentPage(page))) {
this.addClubmateAnnotations()
}
})

$(document).on('leaderboard-annotated', (event, data) => this.addClubmateAnnotations(data))

this.hasRun = true
}

async addClubmateAnnotations (data) {
const selector = (data && data.selector) || ''
const clubStatus = Helpers.lsGet(lsKeys.CLUB_STATUS)
const nameColumnSelector = this.getNameColumnSelector()

if (clubStatus && clubStatus.memberIds) {
clubStatus.memberIds.forEach((id) => {
if (id === `${window.Hero.infos.id}`) {return}
$(`${selector} [sorting_id='${id}']`).find(nameColumnSelector).append(`<div class="script-flair script-clubmate"><span class="globalClubs_mix_icn" tooltip="${this.label('clubmate')}"/></div>`)
})
}
}

getNameColumnSelector () {
if (Helpers.isCurrentPage('activities')) {
return 'td:nth-of-type(2)'
} else if (Helpers.isCurrentPage('tower-of-fame')) {
return '.nickname'
}
return '> div:nth-of-type(2)'
}
}

export default LeaderboardClubmateIndicatorsModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.script-flair.script-clubmate {
.globalClubs_mix_icn {
margin: 0;
margin-left: 5px;
height: 21px;
width: 21px;
background-size: contain;
}
}
76 changes: 76 additions & 0 deletions src/modules/LeaderboardSupportersIndicatorsModule/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import CoreModule from '../CoreModule'
import Helpers from '../../common/Helpers'
import I18n from '../../i18n'

import tierIconGold from '../../assets/hh-plus-plus-gold.svg'
import tierIconSilver from '../../assets/hh-plus-plus-silver.svg'

import styles from './styles.lazy.scss'
import Supporters from '../../data/Supporters'

const MODULE_KEY = 'leaderboardSupportersIndicators'

const TIER_ICONS = {
gold: tierIconGold,
silver: tierIconSilver,
}

class LeaderboardSupportersIndicatorsModule extends CoreModule {
constructor () {
super({
baseKey: MODULE_KEY,
default: true
})
this.label = I18n.getModuleLabel.bind(this, MODULE_KEY)
}

shouldRun () {
return ['activities', 'tower-of-fame', 'pantheon', 'season.html', 'path-of-valor', 'path-of-glory'].some(page => Helpers.isCurrentPage(page))
}

run () {
if (this.hasRun || !this.shouldRun()) {return}

styles.use()

Helpers.defer(() => {
if (['activities', 'tower-of-fame'].some(page => Helpers.isCurrentPage(page))) {
this.addSupporterAnnotations()
}
})

$(document).on('leaderboard-annotated', (event, data) => this.addSupporterAnnotations(data))

this.hasRun = true
}

async addSupporterAnnotations (data) {
const selector = (data && data.selector) || ''
const supporters = await Supporters.getSupporters()
const filteredSupporters = supporters.filter(({flairs}) => flairs)

const gameKey = Helpers.getGameKey()
const gamePlatform = Helpers.getPlatform()

const nameColumnSelector = this.getNameColumnSelector()

filteredSupporters.forEach(({tier, flairs}) => {
flairs.forEach(({game, platform, id}) => {
if (game === gameKey && platform === gamePlatform) {
$(`${selector} [sorting_id='${id}']`).find(nameColumnSelector).append(`<div class="script-flair script-supporter"><img class="tier-icon" src="${TIER_ICONS[tier]}" tooltip="HH++ ${tier.substring(0,1).toUpperCase()}${tier.substring(1)} Tier Supporter"/></div>`)
}
})
})
}

getNameColumnSelector () {
if (Helpers.isCurrentPage('activities')) {
return 'td:nth-of-type(2)'
} else if (Helpers.isCurrentPage('tower-of-fame')) {
return '.nickname'
}
return '> div:nth-of-type(2)'
}
}

export default LeaderboardSupportersIndicatorsModule
12 changes: 12 additions & 0 deletions src/modules/LeaderboardSupportersIndicatorsModule/styles.lazy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.script-flair {
display: inline-flex;
height: 100%;
flex-direction: column;
justify-content: center;

.tier-icon {
display: inline-block;
margin-left: 5px;
height: 21px;
}
}
5 changes: 0 additions & 5 deletions src/modules/ResourceBarsModule/styles.lazy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,6 @@ body#hh_comix > div > header div[rel="xp"] {
}
}

#contests > div > div.right_part img {
height: 286px;
margin-top: -74px;
}

@media #{$mediaMobile} {
body > div > header {
& > a.hh_logo,
Expand Down
1 change: 1 addition & 0 deletions src/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export {default as FixProfilePopupModule} from './FixProfilePopupModule'
export {default as EventEndIndicatorsModule} from './EventEndIndicatorsModule'
export {default as HaremTeamsFilterModule} from './HaremTeamsFilterModule'
export {default as UpgradeQuickNavModule} from './UpgradeQuickNavModule'
export {default as LeaderboardClubmateIndicatorsModule} from './LeaderboardClubmateIndicatorsModule'

export {default as HomeScreenRightSideRearrangeStyleTweak} from './HomeScreenRightSideRearrangeStyleTweak'
export {default as ContestNotifsStyleTweak} from './ContestNotifsStyleTweak'
Expand Down

0 comments on commit 02a75a2

Please sign in to comment.