Skip to content

Instantly share code, notes, and snippets.

@Getaji
Last active February 7, 2022 04:21
Show Gist options
  • Save Getaji/0a29dfae7ba55b17df7e338bc3a5158d to your computer and use it in GitHub Desktop.
Save Getaji/0a29dfae7ba55b17df7e338bc3a5158d to your computer and use it in GitHub Desktop.
Mocha-RepositoryのLevel Reviewのレベル評価とコメントをアラートポップアップでリスト表示するスクリプト

image

Mocha-RepositoryのLevel Reviewのレベル評価とコメントをアラートポップアップでリスト表示するスクリプトです。以下の javascript: から末尾までの一行をブックマークレットとして使用できます。

javascript:(()=>{const a=a=>Number.isInteger(a)?a:+a.toFixed(2),b=b=>doubleplay?12<=b?"\u2605"+a(b-11):"\u2606"+a(b):13<=b?"\u2605"+a(b-12):"\u2606"+a(b),c=scores.filter(a=>0<a.level);alert([document.querySelector("h1").textContent.trim(),c.length+"\u4EF6\u306E\u30EC\u30D3\u30E5\u30FC",...c.map(a=>b(a.level)+" "+a.comment)].join("\n"))})();

偏差値を載せる案もありますが、整形が面倒なのと余計な情報になるかもしれないので実装するかは未定です。

プレイヤー名は意図的に載せていないので、欲しい場合は改変して使ってください。

関連: Mocha-Repositoryの楽曲ページでLevel Reviewの平均、中央値、範囲、分散、標準偏差を表示するスクリプト

(() => {
// 小数部の下3桁以降を四捨五入
const fixNumber = (n) => Number.isInteger(n) ? n : Number((n).toFixed(2));
// レベルの数値を通常/発狂レベル表記の文字列に変換する
const formatLevel = (v) => {
if (doubleplay) {
return v >= 12 ? "★" + fixNumber(v - 11) : "☆" + fixNumber(v);
}
return v >= 13 ? "★" + fixNumber(v - 12) : "☆" + fixNumber(v);
}
const reviews = scores.filter((score) => score.level > 0);
alert([
document.querySelector("h1").textContent.trim(),
reviews.length + "件のレビュー",
...reviews.map((score) => formatLevel(score.level) + " " + score.comment),
].join("\n"))
})();
(()=>{const a=a=>Number.isInteger(a)?a:+a.toFixed(2),b=b=>doubleplay?12<=b?"\u2605"+a(b-11):"\u2606"+a(b):13<=b?"\u2605"+a(b-12):"\u2606"+a(b),c=scores.filter(a=>0<a.level);alert([document.querySelector("h1").textContent.trim(),c.length+"\u4EF6\u306E\u30EC\u30D3\u30E5\u30FC",...c.map(a=>b(a.level)+" "+a.comment)].join("\n"))})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment