Greasy Fork is available in English.

AtCoder Profile2Ranking Link

link the profile page to the ranking of country/region, birth year, and affiliation

  1. // ==UserScript==
  2. // @name AtCoder Profile2Ranking Link
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description link the profile page to the ranking of country/region, birth year, and affiliation
  6. // @author sotanishy
  7. // @match https://atcoder.jp/users/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Your code here...
  15. let table = document.getElementsByClassName('dl-table')[0];
  16. let tbody = table.getElementsByTagName('tbody')[0];
  17. let tr = tbody.getElementsByTagName('tr');
  18. const baseUrl = 'https://atcoder.jp/ranking';
  19.  
  20. for (let i = 0; i < tr.length; i++) {
  21. let head = tr[i].getElementsByTagName('th')[0].textContent;
  22. let td = tr[i].getElementsByTagName('td')[0];
  23. if (head == '国と地域' || head == 'Country/Region') {
  24. let img = td.getElementsByTagName('img')[0];
  25. let country = img.src.split('/')[5].split('.')[0];
  26. let a = document.createElement('a');
  27. a.textContent = td.textContent;
  28. td.textContent = '';
  29. a.href = `${baseUrl}?f.Country=${country}`;
  30. td.appendChild(img);
  31. td.appendChild(a);
  32. }
  33. if (head == '誕生年' || head == 'Birth Year') {
  34. let birthyear = td.textContent;
  35. let a = document.createElement('a');
  36. a.textContent = birthyear;
  37. td.textContent = '';
  38. a.href = `${baseUrl}?f.BirthYearLowerBound=${birthyear}&f.BirthYearUpperBound=${birthyear}`;
  39. td.appendChild(a);
  40. }
  41. if (head == '所属' || head == 'Affiliation') {
  42. let affiliation = td.textContent;
  43. let a = document.createElement('a');
  44. a.textContent = affiliation;
  45. td.textContent = '';
  46. a.href = `${baseUrl}?f.Affiliation=${affiliation.replace(' ', '+')}`;
  47. td.appendChild(a);
  48. }
  49. }
  50. })();