Skip to content
This repository was archived by the owner on Feb 14, 2022. It is now read-only.

Commit e0a12c6

Browse files
committed
Added solved.ac tier information to user page
1 parent 44cdd33 commit e0a12c6

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

content.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ function isProblemPage() {
147147
return pattern.test(url)
148148
}
149149

150+
function isUserPage() {
151+
const url = window.location.toString()
152+
const pattern = /^https?:\/\/www\.acmicpc\.net\/(user)\/[A-Za-z0-9_]+$/i
153+
return pattern.test(url)
154+
}
155+
150156
function isNotUserOrVsPage() {
151157
const url = window.location.toString()
152158
const pattern = /^https?:\/\/www\.acmicpc\.net\/(user|vs)\/.*$/i
@@ -238,4 +244,25 @@ if (isNotUserOrVsPage()) {
238244
})
239245
}
240246

247+
if (isUserPage()) {
248+
// TODO add solved.ac tier
249+
var userId = document.querySelector(".page-header h1").innerText.trim()
250+
var userStaticsTable = document.querySelector("#statics tbody")
251+
getJson("https://api.solved.ac/user_information.php?id=" + userId, function (userData) {
252+
if (!userData) return
253+
var newRow = document.createElement("tr")
254+
var newRowHeader = document.createElement("th")
255+
newRowHeader.innerText = "solved.ac"
256+
var newRowDescription = document.createElement("td")
257+
newRowDescription.innerHTML = "<a href=\"https://solved.ac/" + userData.user_id + "\">"
258+
+ "<span class=\"text-" + levelCssClass(userData.level) + "\">"
259+
+ levelLabel(userData.level) + "<b>" + userData.user_id + "</b>"
260+
+ "</span>"
261+
+ "</a>"
262+
newRow.appendChild(newRowHeader)
263+
newRow.appendChild(newRowDescription)
264+
userStaticsTable.appendChild(newRow)
265+
})
266+
}
267+
241268
$('.dropdown-toggle').dropdown()

0 commit comments

Comments
 (0)