CodeForces Performance

You can check your performance for each contest!

Verze ze dne 28. 04. 2020. Zobrazit nejnovější verzi.

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