|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name LeetCodeRating|显示力扣周赛难度分
|
3 | 3 | // @namespace https://github.com/zhang-wangz
|
4 |
| -// @version 1.1.7 |
| 4 | +// @version 1.1.8 |
5 | 5 | // @license MIT
|
6 | 6 | // @description LeetCodeRating 力扣周赛分数显现,目前支持tag页面,题库页面和题目页面
|
7 | 7 | // @author 小东是个阳光蛋(力扣名
|
|
23 | 23 | // @note 2022-09-08 1.1.5 修复tag页面跳转problems页面bug
|
24 | 24 | // @note 2022-09-08 1.1.6 增加描述,更新插件范围为全体界面,在其他界面时删除功能优化性能
|
25 | 25 | // @note 2022-09-08 1.1.7 增强数据管理,每天只获取一遍分数数据,优化效率
|
| 26 | +// @note 2022-09-09 1.1.8 修复pb页面点击下一页难度分没有变化的bug |
26 | 27 | // ==/UserScript==
|
27 | 28 |
|
28 | 29 | (function () {
|
|
73 | 74 | t2rate = JSON.parse(GM_getValue("t2ratedb", "{}").toString())
|
74 | 75 | preDate = GM_getValue("preDate", "")
|
75 | 76 | let now = getCurrentDate(1)
|
76 |
| - if (t2rate["idx"] == undefined || (preDate == "" || preDate != now)) { |
| 77 | + if (t2rate["idx"] == undefined || (preDate == "" || preDate != now)) { |
77 | 78 | GM_xmlhttpRequest({
|
78 | 79 | method: "get",
|
79 | 80 | url: 'https://zerotrac.github.io/leetcode_problem_rating/data.json',
|
|
185 | 186 | clearInterval(all)
|
186 | 187 | clearInterval(tag)
|
187 | 188 |
|
188 |
| - let tmp |
189 |
| - let t |
| 189 | + let le |
| 190 | + let t1 |
190 | 191 |
|
191 | 192 | function getpb() {
|
192 | 193 | if (!window.location.href.startsWith(pbUrl)) {
|
|
200 | 201 | let t = document.querySelector("#question-detail-main-tabs > div.css-1qqaagl-layer1.css-12hreja-TabContent.e16udao5 > div > div.css-xfm0cl-Container.eugt34i0 > h4 > a")
|
201 | 202 | let data = t.innerText.split(".")
|
202 | 203 | let title = data[data.length - 1].trim()
|
203 |
| - if (t != undefined && t == title) { |
| 204 | + if (t1 != undefined && t1 == title) { |
204 | 205 | return
|
205 | 206 | }
|
| 207 | + |
206 | 208 | let colorSpan = document.querySelector("#question-detail-main-tabs > div.css-1qqaagl-layer1.css-12hreja-TabContent.e16udao5 > div > div.css-xfm0cl-Container.eugt34i0 > div > span:nth-child(2)")
|
207 |
| - if (tmp != undefined && tmp === colorSpan.parentNode.childNodes.length) { |
208 |
| - return |
209 |
| - } |
210 |
| - let span = document.createElement("span") |
211 |
| - span.setAttribute("class", colorSpan.getAttribute("class")) |
212 |
| - span.setAttribute("data-degree", colorSpan.getAttribute("data-degree")) |
213 |
| - if (t2rate[title] != undefined) { |
214 |
| - span.innerHTML = "难度分: " + t2rate[title] |
| 209 | + let pa = colorSpan.parentNode |
| 210 | + console.log("le: " + le) |
| 211 | + if (le != undefined && le === colorSpan.parentNode.childNodes.length) { |
| 212 | + if (t2rate[title] != undefined) { |
| 213 | + pa.childNodes[2].innerHTML = "难度分: " + t2rate[title] |
| 214 | + } else { |
| 215 | + pa.childNodes[2].innerHTML = "难度分未知" |
| 216 | + } |
| 217 | + pa.childNodes[2].setAttribute("class", colorSpan.getAttribute("class")) |
| 218 | + pa.childNodes[2].setAttribute("data-degree", colorSpan.getAttribute("data-degree")) |
215 | 219 | } else {
|
216 |
| - span.innerHTML = "难度分未知" |
| 220 | + let span = document.createElement("span") |
| 221 | + span.setAttribute("class", colorSpan.getAttribute("class")) |
| 222 | + span.setAttribute("data-degree", colorSpan.getAttribute("data-degree")) |
| 223 | + if (t2rate[title] != undefined) { |
| 224 | + span.innerHTML = "难度分: " + t2rate[title] |
| 225 | + } else { |
| 226 | + span.innerHTML = "难度分未知" |
| 227 | + } |
| 228 | + pa.insertBefore(span, pa.childNodes[2]) |
217 | 229 | }
|
218 |
| - let pa = colorSpan.parentNode |
219 |
| - pa.insertBefore(span, pa.childNodes[2]) |
220 |
| - tmp = deepclone(pa.childNodes.length) |
221 |
| - t = deepclone(title) |
| 230 | + le = deepclone(pa.childNodes.length) |
| 231 | + t1 = deepclone(title) |
222 | 232 | } catch (e) {
|
223 | 233 | return
|
224 | 234 | }
|
|
0 commit comments