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

Commit e272d3f

Browse files
committed
Trivial fixes
1 parent e0a12c6 commit e272d3f

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

content.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,20 @@ function kudekiLevelLabel(level) {
141141
return "<img class=\"level_badge small\" style=\"width: 1.1em;height: 1.4em;\" src=\"" + chrome.extension.getURL("svg/ka" + level + ".svg") + "\">"
142142
}
143143

144+
function matchCurrentURL(regex) {
145+
return regex.test(window.location.toString())
146+
}
147+
144148
function isProblemPage() {
145-
const url = window.location.toString()
146-
const pattern = /^https?:\/\/www\.acmicpc\.net\/problem\/[0-9]+\/?$/i
147-
return pattern.test(url)
149+
return matchCurrentURL(/^https?:\/\/www\.acmicpc\.net\/problem\/[0-9]+\/?$/i)
148150
}
149151

150152
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)
153+
return matchCurrentURL(/^https?:\/\/www\.acmicpc\.net\/(user)\/[A-Za-z0-9_]+$/i)
154154
}
155155

156156
function isNotUserOrVsPage() {
157-
const url = window.location.toString()
158-
const pattern = /^https?:\/\/www\.acmicpc\.net\/(user|vs)\/.*$/i
159-
return !pattern.test(url)
157+
return !matchCurrentURL(/^https?:\/\/www\.acmicpc\.net\/(user|vs)\/.*$/i)
160158
}
161159

162160
if (isProblemPage()) {
@@ -245,7 +243,6 @@ if (isNotUserOrVsPage()) {
245243
}
246244

247245
if (isUserPage()) {
248-
// TODO add solved.ac tier
249246
var userId = document.querySelector(".page-header h1").innerText.trim()
250247
var userStaticsTable = document.querySelector("#statics tbody")
251248
getJson("https://api.solved.ac/user_information.php?id=" + userId, function (userData) {

0 commit comments

Comments
 (0)