Codeforces Performance

You can check your performance for each contest!

As of 2020-04-28. See the latest version.

  1. // ==UserScript==
  2. // @name Codeforces Performance
  3. // @name:ja Codeforces Performance
  4. // @namespace https://github.com/Coki628/cf-perf
  5. // @version 1.0.3
  6. // @description You can check your performance for each contest!
  7. // @description:ja Codeforcesのコンテストでのパフォーマンス推定値を確認します。
  8. // @author Coki628
  9. // @include https://codeforces.com/contests/with/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // ---------- your settings hare ----------
  14.  
  15. // colorize your rate (1 or 0)
  16. const colorRate = 1;
  17. // colorize your perf (1 or 0)
  18. const colorPerf = 1;
  19. // show your perf (1 or 0)
  20. const showPerf = 1;
  21.  
  22. // ----------------------------------------
  23.  
  24. let getColorType = function(x) {
  25. if (x >= 3000) {
  26. return 'user-legendary';
  27. } else if (3000 > x && x >= 2400) {
  28. return 'user-red';
  29. } else if (2400 > x && x >= 2100) {
  30. return 'user-orange';
  31. } else if (2100 > x && x >= 1900) {
  32. return 'user-violet';
  33. } else if (1900 > x && x >= 1600) {
  34. return 'user-blue';
  35. } else if (1600 > x && x >= 1400) {
  36. return 'user-cyan';
  37. } else if (1400 > x && x >= 1200) {
  38. return 'user-green';
  39. } else {
  40. return 'user-gray';
  41. }
  42. }
  43.  
  44. $(function() {
  45. 'use strict';
  46.  
  47. // 必要な要素を取得
  48. let $thead = $('table.user-contests-table>thead');
  49. let $tbody = $('table.user-contests-table>tbody');
  50. let th = $thead.find('th');
  51. let tr = $tbody.find('tr');
  52.  
  53. // ヘッダ行に列を追加
  54. if (showPerf) {
  55. let $head = $(th[5]).clone();
  56. $head.text('Performance');
  57. $(th[5]).after($head);
  58. }
  59.  
  60. // 各行
  61. for (let i=0; i<tr.length; i++) {
  62. // 変化量とレートを取得
  63. let td = $(tr[i]).find('td');
  64. let change = Number($(td[4]).text());
  65. let $rate = $(td[5]);
  66. let rate = Number($rate.text());
  67.  
  68. // パフォーマンス列を表示
  69. if (showPerf) {
  70. // パフォーマンスを計算
  71. let prev = rate - change;
  72. let perf = prev + change * 4;
  73. // 列を追加
  74. let $perf = $rate.clone();
  75. $perf.text(perf);
  76. $rate.after($perf);
  77. // パフォーマンスの色付け
  78. if (colorPerf) {
  79. let colorType = getColorType(perf);
  80. $perf.addClass(colorType);
  81. $perf.css('font-weight', 'bold');
  82. }
  83. }
  84. // レートの色付け
  85. if (colorRate) {
  86. let colorType = getColorType(rate);
  87. $rate.addClass(colorType);
  88. $rate.css('font-weight', 'bold');
  89. }
  90. }
  91. });