Greasy Fork is available in English.

显示YouTube好评/差评比例(好评占比)

治好了我每次看到好评和差评时都忍不住心算一下好评占比的强迫症

< Feedback on 显示YouTube好评/差评比例(好评占比)

Question/comment

§
Posted: 2020/03/31

无法正常显示百分比

将 let upCount = up.getAttribute('aria-label'); let downCount = down.getAttribute('aria-label'); 改为 let upCount = up.textContent; let downCount = down.textContent; 后恢复正常.

SSmJaEAuthor
§
Posted: 2020/03/31

@"锦年" 说道: 将 let upCount = up.getAttribute('aria-label'); let downCount = down.getAttribute('aria-label'); 改为 let upCount = up.textContent; let downCount = down.textContent; 后恢复正常.

<3 textContent的话,我这显示的是简写,比如“21万”,不会显示万之后的数字,不精确。感觉可以try catch一下,我这边完整的点赞数就是在aria-label这个属性里面的,不知道你那边是咋样的,能截图就最好了

SSmJaEAuthor
§
Posted: 2020/03/31

§
Posted: 2020/04/01

我用的是繁体中文

SSmJaEAuthor
§
Posted: 2020/04/01

@"锦年" 说道: 我用的是繁体中文

replace(/[^0-9]/ig,"")这样就行了,我回头改一下

§
Posted: 2020/04/02

还有个例外 当点赞数或点踩数为0时,label里不会有任何数字导致错误 改为 upCount = parseInt(upCount) ? parseInt(upCount) : 0; downCount = parseInt(downCount) ? parseInt(downCount) : 0; 后正常.

SSmJaEAuthor
§
Posted: 2020/04/03

@"锦年" 说道: 还有个例外 当点赞数或点踩数为0时,label里不会有任何数字导致错误 改为 upCount = parseInt(upCount) ? parseInt(upCount) : 0; downCount = parseInt(downCount) ? parseInt(downCount) : 0; 后正常.

改了 B)

Post reply

Sign in to post a reply.