Skip to content

Instantly share code, notes, and snippets.

@alxtz
Last active March 30, 2022 05:43
Show Gist options
  • Save alxtz/ecff328208d83b3aab8907ec04d7bb27 to your computer and use it in GitHub Desktop.
Save alxtz/ecff328208d83b3aab8907ec04d7bb27 to your computer and use it in GitHub Desktop.
其實不是什麼高深的東西,給大家複製來自己改,有語法問題可以問 twitch: alex_tzeng
!commands edit -cd=5 !亞服
$(eval
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=AP&leaderboardId=BG&seasonId=3);
let r = api.leaderboard.rows;
let q = "$(1)";
let rest = q.substring(1, q.length);
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase());
f === undefined ? `[$(user)]: ${q} 不在亞服排行榜,沒料` : `[$(user)]: ${f.accountid} 目前亞服 #${f.rank},${f.rating}分`;
)
!commands edit -cd=5 !美服
$(eval
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=US&leaderboardId=BG&seasonId=3);
let r = api.leaderboard.rows;
let q = "$(1)";
let rest = q.substring(1, q.length);
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase());
f === undefined ? `[$(user)]: ${q} 不在美服排行榜,沒料` : `[$(user)]: ${f.accountid} 目前美服 #${f.rank},${f.rating}分`;
)
!commands edit -cd=5 !歐服
$(eval
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=EU&leaderboardId=BG&seasonId=3);
let r = api.leaderboard.rows;
let q = "$(1)";
let rest = q.substring(1, q.length);
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase());
f === undefined ? `[$(user)]: ${q} 不在歐服排行榜,沒料` : `[$(user)]: ${f.accountid} 目前歐服 #${f.rank},${f.rating}分`;
)
@alxtz
Copy link
Author

alxtz commented Feb 3, 2021

Changelog v1.0.0

[zh-TW]

  1. 增加美、歐、亞三服查詢方式。
  2. https://gist.github.com/alxtz/ecff328208d83b3aab8907ec04d7bb27#file-bg-search-js-L3 為搜尋字串的別名字典。
  3. https://gist.github.com/alxtz/ecff328208d83b3aab8907ec04d7bb27#file-bg-search-js-L7 支援使用大小寫不分的字串做搜尋。

[en-US]

  1. Support querying through US, EU, and Asia servers
  2. https://gist.github.com/alxtz/ecff328208d83b3aab8907ec04d7bb27#file-bg-search-js-L3 Represents the alias ​​dictionary for query strings.
  3. https://gist.github.com/alxtz/ecff328208d83b3aab8907ec04d7bb27#file-bg-search-js-L7 Supports case-insensitive searching.

TODO

  1. 戰場賽季改版後會需要更新,因為 https://gist.github.com/alxtz/ecff328208d83b3aab8907ec04d7bb27#file-bg-search-js-L4 使用的 seasonId 是寫死的第三季 (seasonId=2)
  2. 搜尋失敗時顯示 q 字串,並且 tag 當初呼叫搜尋的人

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment