@@ -137,56 +137,6 @@ async function addLevelIndicators() {
137137
138138 var standard = ( difficultyVotes . length > 0 && difficultyVotes [ 0 ] . user_id == "solvedac" )
139139
140- const hideOtherVotes = JSON . parse ( await getPrefs ( 'hide_other_votes' , 'false' ) )
141- const showTagsInEnglish = JSON . parse ( await getPrefs ( 'show_tags_in_english' , 'false' ) )
142-
143- if ( ! document . querySelector ( ".label-success" ) && nick !== "solvedac" ) return
144- if ( levelData . level != 0 && ! standard ) {
145- var difficultyVotesContainer = document . createElement ( "div" ) ;
146- difficultyVotesContainer . className = "difficulty_vote_container"
147-
148- for ( var i = 0 ; i < difficultyVotes . length ; i ++ ) {
149- var vote = difficultyVotes [ i ]
150- if ( vote . user_id === nick ) {
151- votedFlag = true
152- myVote = vote
153- }
154- if ( hideOtherVotes ) continue
155-
156- var difficultyVote = document . createElement ( "div" )
157- difficultyVote . className = "difficulty_vote"
158- difficultyVote . innerHTML = "<a href=\"/user/" + vote . user_id + "\">"
159- + "<span class=\"text-" + levelCssClass ( vote . user_level ) + "\">"
160- + levelLabel ( vote . user_level ) + vote . user_id
161- + "</span>"
162- + "</a> ➔ " + levelLabel ( vote . voted_level )
163- difficultyVote . appendChild ( document . createElement ( "br" ) )
164-
165- var voteComment = document . createElement ( "div" )
166- voteComment . innerText = vote . comment
167- if ( ! vote . comment ) {
168- voteComment . classList . add ( "comment_none" )
169- voteComment . innerText = "난이도 의견을 입력하지 않았습니다"
170- }
171- if ( vote . algorithms ) {
172- for ( var j = 0 ; j < vote . algorithms . length ; j ++ ) {
173- var algo = vote . algorithms [ j ]
174- var algorithmTag = document . createElement ( "div" )
175- if ( showTagsInEnglish ) {
176- algorithmTag . innerText = algo . full_name_en
177- } else {
178- algorithmTag . innerText = algo . full_name_ko
179- }
180- algorithmTag . className = "algorithm_tag"
181- voteComment . appendChild ( algorithmTag )
182- }
183- }
184- difficultyVote . appendChild ( voteComment )
185- difficultyVotesContainer . appendChild ( difficultyVote )
186- }
187- problemInfo . appendChild ( difficultyVotesContainer )
188- }
189-
190140 if ( standard ) {
191141 var standardIndicator = document . createElement ( "img" )
192142 standardIndicator . src = chrome . extension . getURL ( "svg/mark-verified.svg" )
@@ -197,7 +147,7 @@ async function addLevelIndicators() {
197147 standardIndicator . alt = "solved.ac 표준"
198148 standardIndicator . title = "solved.ac 표준"
199149 problemInfo . appendChild ( standardIndicator )
200-
150+
201151 if ( nick === "solvedac" ) {
202152 for ( var i = 0 ; i < difficultyVotes . length ; i ++ ) {
203153 var vote = difficultyVotes [ i ]
@@ -208,25 +158,76 @@ async function addLevelIndicators() {
208158 }
209159 }
210160 }
211-
212- if ( ! standard || nick === "solvedac" ) {
213- var defaultLevel = 1
214- if ( levelData . level ) defaultLevel = levelData . level
215- if ( votedFlag ) defaultLevel = myVote . voted_level
216- initializeVoting ( problemId , defaultLevel , myVote )
161+
162+ const hideOtherVotes = JSON . parse ( await getPrefs ( 'hide_other_votes' , 'false' ) )
163+ const showTagsInEnglish = JSON . parse ( await getPrefs ( 'show_tags_in_english' , 'false' ) )
164+
165+ if ( document . querySelector ( ".label-success" ) || nick === "solvedac" ) {
166+ if ( levelData . level != 0 && ! standard ) {
167+ var difficultyVotesContainer = document . createElement ( "div" ) ;
168+ difficultyVotesContainer . className = "difficulty_vote_container"
169+
170+ for ( var i = 0 ; i < difficultyVotes . length ; i ++ ) {
171+ var vote = difficultyVotes [ i ]
172+ if ( vote . user_id === nick ) {
173+ votedFlag = true
174+ myVote = vote
175+ }
176+ if ( hideOtherVotes ) continue
177+
178+ var difficultyVote = document . createElement ( "div" )
179+ difficultyVote . className = "difficulty_vote"
180+ difficultyVote . innerHTML = "<a href=\"/user/" + vote . user_id + "\">"
181+ + "<span class=\"text-" + levelCssClass ( vote . user_level ) + "\">"
182+ + levelLabel ( vote . user_level ) + vote . user_id
183+ + "</span>"
184+ + "</a> ➔ " + levelLabel ( vote . voted_level )
185+ difficultyVote . appendChild ( document . createElement ( "br" ) )
186+
187+ var voteComment = document . createElement ( "div" )
188+ voteComment . innerText = vote . comment
189+ if ( ! vote . comment ) {
190+ voteComment . classList . add ( "comment_none" )
191+ voteComment . innerText = "난이도 의견을 입력하지 않았습니다"
192+ }
193+ if ( vote . algorithms ) {
194+ for ( var j = 0 ; j < vote . algorithms . length ; j ++ ) {
195+ var algo = vote . algorithms [ j ]
196+ var algorithmTag = document . createElement ( "div" )
197+ if ( showTagsInEnglish ) {
198+ algorithmTag . innerText = algo . full_name_en
199+ } else {
200+ algorithmTag . innerText = algo . full_name_ko
201+ }
202+ algorithmTag . className = "algorithm_tag"
203+ voteComment . appendChild ( algorithmTag )
204+ }
205+ }
206+ difficultyVote . appendChild ( voteComment )
207+ difficultyVotesContainer . appendChild ( difficultyVote )
208+ }
209+ problemInfo . appendChild ( difficultyVotesContainer )
210+ }
211+
212+ if ( ! standard || nick === "solvedac" ) {
213+ var defaultLevel = 1
214+ if ( levelData . level ) defaultLevel = levelData . level
215+ if ( votedFlag ) defaultLevel = myVote . voted_level
216+ initializeVoting ( problemId , defaultLevel , myVote )
217+ }
217218 }
218219 }
219220
220221 if ( isNotUserOrVsPage ( ) ) {
221- var pattern = / ^ [ / ] p r o b l e m [ / ] [ 0 - 9 ] + $ / i
222+ pattern = / ^ ( h t t p s ? : \/ \/ ( w w w \. ) ? a c m i c p c \. n e t ) ? \/ p r o b l e m \/ ( [ 0 - 9 ] + ) $ / i
222223 var problemLinks = document . getElementsByTagName ( "a" )
223224 problemLinks = [ ] . slice . call ( problemLinks , 0 )
224225 problemLinks
225226 . filter ( function ( item ) {
226227 return item . getAttribute ( "href" ) && pattern . test ( item . getAttribute ( "href" ) )
227228 } )
228229 . forEach ( async function ( item , index ) {
229- const problemId = item . getAttribute ( "href" ) . split ( "/" ) [ 2 ]
230+ const problemId = item . getAttribute ( "href" ) . match ( pattern ) [ 3 ]
230231
231232 const levelData = await ( await fetch ( "https://api.solved.ac/problem_level.php?id=" + problemId ) ) . json ( )
232233 if ( levelData . kudeki_level ) {
0 commit comments