Better atcoder friend problemset

Show friend's accepted submissions.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

  1. // ==UserScript==
  2. // @name Better atcoder friend problemset
  3. // @namespace https://atcoder.jp
  4. // @version 0.4
  5. // @description Show friend's accepted submissions.
  6. // @author Ftt2333
  7. // @match https://atcoder.jp/*
  8. // @connect kenkoooo.com
  9. // @connect atcoder.jp
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant GM_xmlhttpRequest
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. var userList
  16. var contestId, problemId
  17.  
  18. let GetColorByRating = (rating) => {
  19. if (rating < 400) return 'user-gray';
  20. if (400 <= rating && rating < 800) return 'user-brown'
  21. if (800 <= rating && rating < 1200) return 'user-green'
  22. if (1200 <= rating && rating < 1600) return 'user-cyan'
  23. if (1600 <= rating && rating < 2000) return 'user-blue'
  24. if (2000 <= rating && rating < 2400) return 'user-yellow'
  25. if (2400 <= rating && rating < 2800) return 'user-orange'
  26. if (2800 <= rating) return 'user-red'
  27. }
  28.  
  29. var result = [], base, node, counter
  30.  
  31. let Display = () => {
  32. console.log(result)
  33. let str1 = "Solved by " + result.length.toString() + " friend" + (result.length > 1 ? "s. " : ". ")
  34. let str2 = ""
  35. for (let i = 0; i < result.length; i++) {
  36. str2 += `<span class = "` + result[i].color + `">` + result[i].userId + "</span>"
  37. if (i + 1 != result.length) str2 += ", "
  38. }
  39. let str = `<br><span style = "font-size: 16px; color: grey;">` + str1 + str2 + (counter == 0 ? "(finished)" : "") + ".</span>"
  40. node.innerHTML = base + str
  41. }
  42.  
  43. let GetUserColor = async (userId) => {
  44. let tmp = {}, cnt = 10
  45. let url = "https://atcoder.jp/users/" + userId
  46. while (cnt >= 0 && tmp.status != 200) tmp = await fetch(url), cnt--
  47. tmp.text().then((data) => {
  48. let tmp = /<tr><th class="no-break">Rating<\/th><td><span class='user-(\w*)'>(\d*)<\/span>/
  49. let arr = tmp.exec(data)
  50. if (arr != null) result.push({userId : userId, color : GetColorByRating(parseInt(arr[2]))})
  51. else result.push({userId : userId, color : "user-unrated"})
  52. Display()
  53. })
  54. }
  55.  
  56. let CheckIfAvailable = async (userId) => {
  57. let tmp = {}, cnt = 10
  58. let url = "https://atcoder.jp/contests/" + contestId + "/submissions?f.Task=" + problemId + "&f.LanguageName=&f.Status=AC&f.User=" + userId
  59. while (cnt >= 0 && tmp.status != 200) tmp = await fetch(url), cnt--
  60. tmp.text().then((data) => {
  61. let tmp = /<span class='label label-success' data-toggle='tooltip' data-placement='top' title="Accepted">AC<\/span>/
  62. let arr = tmp.exec(data)
  63. if (arr != null) GetUserColor(userId)
  64. counter--
  65. })
  66. }
  67. let GetAvailableUsers = async () => {
  68. counter = userList.length
  69. Display()
  70. for (let i = 0; i < userList.length; i++) await CheckIfAvailable(userList[i])
  71. }
  72.  
  73. let Init = () => {
  74. let tmp1 = /atcoder.jp\/contests\/([\w-]*)\/tasks\/([\w-]*)/
  75. let tmp2 = tmp1.exec(location.href)
  76. if (tmp2 == null) return
  77. contestId = tmp2[1], problemId = tmp2[2]
  78. userList = JSON.parse(localStorage.fav)
  79. node = document.querySelector(`#main-div > div.container > div.row > div:nth-child\(2\) > span`)
  80. base = node.innerHTML
  81. GetAvailableUsers()
  82. }
  83.  
  84. Init()