-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐲update 2.2.6: 修改题目页面搜索框查询太频繁导致卡顿的问题,改成没有新输入之后延迟之后再调用查询接口
- Loading branch information
1 parent
05ddc87
commit 899f7ac
Showing
2 changed files
with
23 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// ==UserScript== | ||
// @name LeetCodeRating|显示力扣周赛难度分 | ||
// @namespace https://github.com/zhang-wangz | ||
// @version 2.2.5 | ||
// @version 2.2.6 | ||
// @license MIT | ||
// @description LeetCodeRating 力扣周赛分数显现,支持所有页面评分显示 | ||
// @author 小东是个阳光蛋(力扣名) | ||
|
@@ -161,12 +161,13 @@ | |
// @note 2024-04-17 2.2.3 题目页面全区(题目描述,题解,提交页面) a标签css和leetcode原生css冲突问题修复 | ||
// @note 2024-04-19 2.2.4 题目页css冲突独立成leetcoderatingjs包,去除版本校验只在题库页进行的限制 | ||
// @note 2024-04-22 2.2.5 插件专属css包去除所有基础标签样式渲染,避免与力扣样式冲突 | ||
// @note 2024-04-22 2.2.6 修改题目页面搜索框查询太频繁导致卡顿的问题,改成没有新输入之后延迟之后再调用查询接口 | ||
// ==/UserScript== | ||
|
||
(function () { | ||
'use strict'; | ||
|
||
let version = "2.2.5" | ||
let version = "2.2.6" | ||
// css 渲染 | ||
$(document.body).append(`<link href="https://unpkg.com/[email protected]/index.min.css" rel="stylesheet">`) | ||
|
||
|
@@ -1285,15 +1286,24 @@ | |
this.elem.attr('data-id', obj.id) | ||
} | ||
}); | ||
|
||
$(inst.config.elem).on('input propertychange', function(event) { | ||
let elem = $(this); | ||
let value = elem.val().trim(); | ||
elem.removeAttr('data-id'); | ||
let dataNew = findData(value); | ||
dropdown.reloadData(inst.config.id, { | ||
data: dataNew | ||
}) | ||
let elemInput = $(inst.config.elem) | ||
let lastQueryTime = ''; | ||
let timer; | ||
elemInput.on('input propertychange', function(event) { | ||
clearTimeout(timer); | ||
timer = setTimeout(function() { | ||
let currentTime = Date.now(); | ||
if (currentTime - lastQueryTime >= 800) { | ||
let elem = $(inst.config.elem); | ||
let value = elem.val().trim(); | ||
elem.removeAttr('data-id'); | ||
let dataNew = findData(value); | ||
dropdown.reloadData(inst.config.id, { | ||
data: dataNew | ||
}) | ||
lastQueryTime = currentTime; | ||
} | ||
}, 800); | ||
}); | ||
|
||
$(inst.config.elem).on('blur', function() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "2.2.5", | ||
"content": "插件专属css包去除所有基础标签样式渲染,避免与力扣样式冲突" | ||
"version": "2.2.6", | ||
"content": "修改题目页面搜索框查询太频繁导致卡顿的问题,改成没有新输入之后延迟之后再调用查询接口" | ||
} |