Skip to content

Commit

Permalink
Annotating Season, Pantheon and Po* leaderboards with player IDs (ena…
Browse files Browse the repository at this point in the history
…bler for future modules)
  • Loading branch information
Numbers committed Jan 18, 2023
1 parent 9ee1ef1 commit 1e51b7d
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 83 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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
1.28.21: Improving performance on the mythic equip upgrade page more
Expand Down
17 changes: 14 additions & 3 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.23
// @version 1.28.24
// @match https://*.hentaiheroes.com/*
// @match https://nutaku.haremheroes.com/*
// @match https://*.gayharem.com/*
Expand Down
154 changes: 77 additions & 77 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.23",
"version": "1.28.24",
"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
14 changes: 14 additions & 0 deletions src/common/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@ class Helpers {
})
}

static doWhenSelectorAvailable (selector, callback) {
if ($(selector).length) {
callback()
} else {
const observer = new MutationObserver(() => {
if ($(selector).length) {
observer.disconnect()
callback()
}
})
observer.observe(document.documentElement, {childList: true, subtree: true})
}
}

static isInClub () {
return window.Chat_vars && (window.Chat_vars.CLUB_ID || (window.Chat_vars.CLUB_INFO && window.Chat_vars.CLUB_INFO.id_club))
}
Expand Down
36 changes: 36 additions & 0 deletions src/common/TableAnnotation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Helpers from './Helpers'

class TableAnnotation {
static run () {
Helpers.onAjaxResponse(/action=leaderboard/, (response, opt) => {
const {leaderboard} = response
const searchParams = new URLSearchParams(opt.data)
const feature = searchParams.get('feature')

switch (feature) {
case 'path_of_valor':
TableAnnotation.annotateTable('#pov_leaderboard_tab_container #leaderboard_list', leaderboard)
break
case 'path_of_glory':
TableAnnotation.annotateTable('#pog_leaderboard_tab_container #leaderboard_list', leaderboard)
break
default:
TableAnnotation.annotateTable('#leaderboard_list', leaderboard)
}
})
}

static annotateTable (selector, leaderboard) {
Helpers.doWhenSelectorAvailable(`${selector} .leaderboard_row`, () => {
const $leaderboardList = $(selector)

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

$(document).trigger('leaderboard-annotated', {selector})
})
}
}

export default TableAnnotation
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TimerCollector
} from './collectors'
import Helpers from './common/Helpers'
import TableAnnotation from './common/TableAnnotation'
import Config from './config'
import * as modules from './modules'

Expand All @@ -33,6 +34,8 @@ const runScript = () => {
PathEventCollector.collect()
HaremFilterCollector.collect()

TableAnnotation.run()

// configurable modules

// core
Expand Down

0 comments on commit 1e51b7d

Please sign in to comment.