Greasy Fork is available in English.

Codeforces Performance

You can check your performance for each contest!

  1. // ==UserScript==
  2. // @name Codeforces Performance
  3. // @name:ja Codeforces Performance
  4. // @namespace https://github.com/Coki628/cf-perf
  5. // @version 1.0.9
  6. // @description You can check your performance for each contest!
  7. // @description:ja Codeforcesのコンテストでのパフォーマンス推定値を確認します。
  8. // @author Coki628
  9. // @license MIT
  10. // @include https://codeforces.com/contests/with/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // ---------- your settings hare ----------
  15.  
  16. // colorize your rate (1 or 0)
  17. const colorRate = 1;
  18. // colorize your perf (1 or 0)
  19. const colorPerf = 1;
  20. // show your perf (1 or 0)
  21. const showPerf = 1;
  22.  
  23. // ----------------------------------------
  24.  
  25. let getColorType = function(x) {
  26. if (x >= 3000) {
  27. return 'user-legendary';
  28. } else if (3000 > x && x >= 2400) {
  29. return 'user-red';
  30. } else if (2400 > x && x >= 2100) {
  31. return 'user-orange';
  32. } else if (2100 > x && x >= 1900) {
  33. return 'user-violet';
  34. } else if (1900 > x && x >= 1600) {
  35. return 'user-blue';
  36. } else if (1600 > x && x >= 1400) {
  37. return 'user-cyan';
  38. } else if (1400 > x && x >= 1200) {
  39. return 'user-green';
  40. } else {
  41. return 'user-gray';
  42. }
  43. }
  44.  
  45. $(function() {
  46. 'use strict';
  47.  
  48. // 必要な要素を取得
  49. let $thead = $('table.user-contests-table>thead');
  50. let $tbody = $('table.user-contests-table>tbody');
  51. let th = $thead.find('th');
  52. let tr = $tbody.find('tr');
  53.  
  54. // ヘッダ行に列を追加
  55. if (showPerf) {
  56. let $head = $(th[6]).clone();
  57. $head.text('Performance');
  58. $(th[6]).after($head);
  59. }
  60.  
  61. // 各行
  62. for (let i=0; i<tr.length; i++) {
  63. // 変化量とレートを取得
  64. let td = $(tr[i]).find('td');
  65. let change = Number($(td[5]).text());
  66. let $rate = $(td[6]);
  67. let rate = Number($rate.text());
  68.  
  69. // パフォーマンス列を表示
  70. if (showPerf) {
  71. // パフォーマンスを計算
  72. let prev = rate - change;
  73. let perf = prev + change * 4;
  74. // 列を追加
  75. let $perf = $rate.clone();
  76. $perf.text(perf);
  77. $rate.after($perf);
  78. // パフォーマンスの色付け
  79. if (colorPerf) {
  80. let colorType = getColorType(perf);
  81. $perf.addClass(colorType);
  82. $perf.css('font-weight', 'bold');
  83. }
  84. }
  85. // レートの色付け
  86. if (colorRate) {
  87. let colorType = getColorType(rate);
  88. $rate.addClass(colorType);
  89. $rate.css('font-weight', 'bold');
  90. }
  91. }
  92.  
  93. // ソートが2重にかかってしまうので1回イベントをリセットする
  94. $('table.user-contests-table th').unbind();
  95. // テーブルのソートを再設定
  96. $("table.user-contests-table").tablesorter({
  97. headers: {
  98. 1: { sorter: false },
  99. 2: { sorter: false },
  100. // 列が増えた分、ここを7→8に
  101. 8: { sorter: false },
  102. }
  103. });
  104.  
  105. // ページ幅を狭くしたときにコンテンツがはみ出さないようにする
  106. $('#pageContent > div.datatable > div:nth-child(6)').css('overflow', 'scroll');
  107. });