Skip to content

Commit 10c10bc

Browse files
committed
💡update 1.1.8 修复pb页面点击下一页难度分没有变化的bug
1 parent 96db386 commit 10c10bc

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

leetcodeRating_greasyfork.user.js

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name LeetCodeRating|显示力扣周赛难度分
33
// @namespace https://github.com/zhang-wangz
4-
// @version 1.1.7
4+
// @version 1.1.8
55
// @license MIT
66
// @description LeetCodeRating 力扣周赛分数显现,目前支持tag页面,题库页面和题目页面
77
// @author 小东是个阳光蛋(力扣名
@@ -23,6 +23,7 @@
2323
// @note 2022-09-08 1.1.5 修复tag页面跳转problems页面bug
2424
// @note 2022-09-08 1.1.6 增加描述,更新插件范围为全体界面,在其他界面时删除功能优化性能
2525
// @note 2022-09-08 1.1.7 增强数据管理,每天只获取一遍分数数据,优化效率
26+
// @note 2022-09-09 1.1.8 修复pb页面点击下一页难度分没有变化的bug
2627
// ==/UserScript==
2728

2829
(function () {
@@ -73,7 +74,7 @@
7374
t2rate = JSON.parse(GM_getValue("t2ratedb", "{}").toString())
7475
preDate = GM_getValue("preDate", "")
7576
let now = getCurrentDate(1)
76-
if (t2rate["idx"] == undefined || (preDate == "" || preDate != now)) {
77+
if (t2rate["idx"] == undefined || (preDate == "" || preDate != now)) {
7778
GM_xmlhttpRequest({
7879
method: "get",
7980
url: 'https://zerotrac.github.io/leetcode_problem_rating/data.json',
@@ -185,8 +186,8 @@
185186
clearInterval(all)
186187
clearInterval(tag)
187188

188-
let tmp
189-
let t
189+
let le
190+
let t1
190191

191192
function getpb() {
192193
if (!window.location.href.startsWith(pbUrl)) {
@@ -200,25 +201,34 @@
200201
let t = document.querySelector("#question-detail-main-tabs > div.css-1qqaagl-layer1.css-12hreja-TabContent.e16udao5 > div > div.css-xfm0cl-Container.eugt34i0 > h4 > a")
201202
let data = t.innerText.split(".")
202203
let title = data[data.length - 1].trim()
203-
if (t != undefined && t == title) {
204+
if (t1 != undefined && t1 == title) {
204205
return
205206
}
207+
206208
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"))
215219
} 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])
217229
}
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)
222232
} catch (e) {
223233
return
224234
}

0 commit comments

Comments
 (0)