Greasy Fork is available in English.

AtCoder Rating Cumulative Distribution

Rating分布を累積表示、累積パーセント表示します

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. "use strict";
  2.  
  3. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  4.  
  5. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6.  
  7. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8.  
  9. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  10.  
  11. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  12.  
  13. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  14.  
  15. // ==UserScript==
  16. // @name AtCoder Rating Cumulative Distribution
  17. // @namespace http://aarsalmon.starfree.jp/
  18. // @version 1.0.2
  19. // @description Rating分布を累積表示、累積パーセント表示します
  20. // @author AAAR_Salmon
  21. // @match https://atcoder.jp/users/*?graph=dist
  22. // @grant none
  23. // ==/UserScript==
  24. (function () {
  25. 'use strict';
  26.  
  27. var canvasGraph = document.getElementById('ratingDistributionGraph');
  28.  
  29. var dist = _toConsumableArray(data);
  30.  
  31. var cumDist = _toConsumableArray(data);
  32.  
  33. for (var i = cumDist.length - 1; i > 0; i--) {
  34. cumDist[i - 1] += cumDist[i];
  35. }
  36.  
  37. var totalActiveUsers = cumDist[0];
  38. var percentCumDist = cumDist.map(function (v) {
  39. return Math.round(v / totalActiveUsers * 100 * 1000) / 1000;
  40. });
  41. var parentNode = document.querySelector('[role="group"]').parentNode;
  42. var groupButton = document.createElement('div');
  43. groupButton.classList.add('btn-group', 'btn-group-sm');
  44. groupButton.setAttribute('role', 'group');
  45. var button = document.createElement('button');
  46. button.classList.add('btn', 'btn-default');
  47. button.setAttribute('type', 'button');
  48. var buttonNum = button.cloneNode(false);
  49. buttonNum.innerText = '#';
  50. var buttonCumNum = button.cloneNode(false);
  51. buttonCumNum.innerText = '累積#';
  52. var buttonCumPercent = button.cloneNode(false);
  53. buttonCumPercent.innerText = '累積%';
  54.  
  55. function updateGraphFunction(data) {
  56. return function () {
  57. canvasGraph.width = 640;
  58. canvasGraph.height = 480;
  59. window.data = data;
  60. $(window).load();
  61. };
  62. }
  63.  
  64. buttonNum.onclick = updateGraphFunction(dist);
  65. buttonCumNum.onclick = updateGraphFunction(cumDist);
  66. buttonCumPercent.onclick = updateGraphFunction(percentCumDist);
  67. [buttonNum, buttonCumNum, buttonCumPercent].forEach(function (btn) {
  68. groupButton.appendChild(btn);
  69. });
  70. parentNode.appendChild(groupButton);
  71. })();