提升组卷网的使用体验(三):提升试题清晰度

本文旨在教您如何在不过分破费的情况下提升组卷网的使用体验。

不同的图片差异有多大

原始 优化后
*.png *.svg
1.96 KB 13.1 KB
原始 优化后
*.png?resizew=* *.png
4.42 KB 18.9 KB

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function normalize_q(dom) {
const ool = dom

ool.querySelectorAll("img").forEach(v => {
if (v.src.includes("/formula/")) {
v.src = v.src.replace(".png", ".svg")
}
if (v.src.includes("/dksih/")) {
let tmp = /\?resizew=(\d*)/.exec(v.src)
if (tmp.length != 0) {
v.style.width = tmp[1] + "px"
v.src = v.src.replace(/\?resizew=(\d*)/, "")
v.setAttribute("width", tmp[1])
}
}
})
}

Greasy Fork