Skip to content

Commit

Permalink
Fixing event girl shard counts on villain menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Numbers committed Dec 9, 2022
1 parent 2b26808 commit 7392efa
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
1.28.15: Fixing event girl shard counts on villain menu
1.28.14: Fixing position of game links in the home screen right-side rearrange
1.28.13: Fixing missing mojo icon in season, harem teams filter and champions shard count display after 07/12 update
1.28.12: Pre-empting update that breaks upgrade page quicknav module
Expand Down
6 changes: 3 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.14
// @version 1.28.15
// @match https://*.hentaiheroes.com/*
// @match https://nutaku.haremheroes.com/*
// @match https://*.gayharem.com/*
Expand Down
4 changes: 2 additions & 2 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.14",
"version": "1.28.15",
"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
10 changes: 5 additions & 5 deletions src/collectors/EventVillainsCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { lsKeys } from '../common/Constants'
import Helpers from '../common/Helpers'

class EventVillainsCollector {
static collect () {
static collect() {
Helpers.defer(() => {
EventVillainsCollector.clean()
if (Helpers.hasSearch('tab=event')) {
Expand All @@ -15,7 +15,7 @@ class EventVillainsCollector {
})
}

static clean () {
static clean() {
const eventEndTime = Helpers.lsGetRaw(lsKeys.EVENT_TIME) || 0
const mythicEventEndTime = Helpers.lsGetRaw(lsKeys.MYTHIC_EVENT_TIME) || 0

Expand All @@ -31,23 +31,23 @@ class EventVillainsCollector {
}
}

static collectFromEvent (eventTimeKey, eventVillainsKey) {
static collectFromEvent(eventTimeKey, eventVillainsKey) {
const eventRemainingTime = $('#contains_all #events .nc-panel-header .nc-pull-right #timer').data('seconds-until-event-end')
const eventEndTime = server_now_ts + eventRemainingTime
Helpers.lsSetRaw(eventTimeKey, eventEndTime)

const eventTrolls = []

eventGirls.forEach(girl => {
const {id_girl: id, source, rarity} = girl
const { id_girl: id, source, rarity } = girl
if (source.name !== 'event_troll') {
return
}
const sourceUrl = source.anchor_source.url
const matches = sourceUrl.match(/id_opponent=([0-9]+)/)
if (matches) {
const troll = matches[1]
eventTrolls.push({id, troll, rarity})
eventTrolls.push({ id: `${id}`, troll, rarity })
}
})
Helpers.lsSet(eventVillainsKey, eventTrolls)
Expand Down
52 changes: 26 additions & 26 deletions src/collectors/GirlDictionaryCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ const upsert = (id, data) => {
const collectFromRewards = (rewards) => {
if (rewards && rewards.data && rewards.data.shards) {
girlDictionary = Helpers.getGirlDictionary()
rewards.data.shards.forEach(({id_girl, value}) => {
rewards.data.shards.forEach(({ id_girl, value }) => {
const girlId = `${id_girl}`
upsert(girlId, {shards: Math.min(value, 100)})
upsert(girlId, { shards: Math.min(value, 100) })
})
Helpers.setGirlDictionary(girlDictionary)
}
}
const collectFromAjaxResponseSingular = (response) => {
const {rewards} = response
const { rewards } = response
collectFromRewards(rewards)
}
const collectFromAjaxResponsePlural = (response) => {
const {rewards: rewardsSets} = response
const { rewards: rewardsSets } = response
if (rewardsSets) {
rewardsSets.forEach(collectFromRewards)
}
}
const collectFromAjaxResponseLeagues = (response) => {
const {rewards} = response
if (!rewards) {return}
const {list} = rewards
const { rewards } = response
if (!rewards) { return }
const { list } = rewards
if (list) {
list.forEach(collectFromRewards)
}
}

class GirlDictionaryCollector {
static collect () {
static collect() {
Helpers.defer(() => {
updated = false
girlDictionary = Helpers.getGirlDictionary()
Expand Down Expand Up @@ -80,10 +80,10 @@ class GirlDictionaryCollector {
})
}

static collectFromHarem () {
if (!$('#harem_whole').length) {return}
static collectFromHarem() {
if (!$('#harem_whole').length) { return }
Object.entries(girlsDataList).forEach(([girlId, girl]) => {
const {name, shards: girlShards, class: carac, rarity, nb_grades, fav_graded, graded} = girl
const { name, shards: girlShards, class: carac, rarity, nb_grades, fav_graded, graded } = girl
const shards = (girlShards !== undefined) ? girlShards : 100
const girlClass = parseInt(carac, 10)
const grade = parseInt(nb_grades, 10)
Expand All @@ -106,65 +106,65 @@ class GirlDictionaryCollector {
})
}

static collectFromEventWidget () {
eventGirls.forEach(({id_girl: id, name, shards, class: girlClass, rarity}) => {
static collectFromEventWidget() {
eventGirls.forEach(({ id_girl: id, name, shards, class: girlClass, rarity }) => {
if (shards === undefined) {
shards = 100
}
if (name) {
upsert(id, {name, shards, class: parseInt(girlClass, 10), rarity})
upsert(`${id}`, { name, shards, class: parseInt(girlClass, 10), rarity })
updated = true
}
})
}

static collectFromClubChamp () {
static collectFromClubChamp() {
if (!window.clubChampionsData) {
return
}

const {shards: rewardShards} = clubChampionsData.reward
const { shards: rewardShards } = clubChampionsData.reward

if (!rewardShards || !rewardShards.length) {
return
}

const {id_girl, name, previous_value: shards, girl_class, rarity} = rewardShards[0]
const { id_girl, name, previous_value: shards, girl_class, rarity } = rewardShards[0]

upsert(id_girl, {name, shards, class: parseInt(girl_class, 10), rarity})
upsert(`${id_girl}`, { name, shards, class: parseInt(girl_class, 10), rarity })
updated = true
}

static collectFromBattleResult () {
static collectFromBattleResult() {
Helpers.onAjaxResponse(/action=do_battles_(leagues|seasons|troll)/i, collectFromAjaxResponseSingular)
}

static collectFromPachinkoRewards () {
static collectFromPachinkoRewards() {
Helpers.onAjaxResponse(/action=play/i, collectFromAjaxResponseSingular)
}

static collectFromContestRewards () {
static collectFromContestRewards() {
Helpers.onAjaxResponse(/action=give_reward/i, collectFromAjaxResponseSingular)
}

static collectFromChampions () {
static collectFromChampions() {
Helpers.onAjaxResponse(/class=TeamBattle/i, (response) => {
const {end} = response
const { end } = response
if (end) {
collectFromAjaxResponseSingular(end)
}
})
}

static collectFromRewardsQueue () {
static collectFromRewardsQueue() {
Helpers.onAjaxResponse(/action=process_rewards_queue/i, collectFromAjaxResponsePlural)
}

static collectFromSeasons () {
static collectFromSeasons() {
Helpers.onAjaxResponse(/action=claim/i, collectFromAjaxResponseSingular)
}

static collectFromLeague () {
static collectFromLeague() {
Helpers.onAjaxResponse(/action=claim_rewards/i, collectFromAjaxResponseLeagues)
}
}
Expand Down

0 comments on commit 7392efa

Please sign in to comment.