Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the original card is cleared #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gaogaotiantian
Copy link
Owner

card.style.display = "none";会出现一个racing condition,因为B站自己的代码是改display的,有可能biliscope先设置成none,然后B站把display又调回去了,就会导致两个card都存在,很容易复现。

这里尽可能把card给藏起来,visibility是B站现在没用的方式,hidden在某些页面(视频下)是工作的,所以全用上。

@F-park
Copy link
Contributor

F-park commented Oct 8, 2024

这么改的话,直接在 enable 函数里执行一次 clearOriginalCard 函数就能把所有的 card 给永久藏起来,就不需要这个观察者和其他位置的 clearOriginalCard 函数了吧。

biliscope/scripts/ui.js

Lines 301 to 305 in 5f4936b

this.idCardObserver = new MutationObserver((mutationList, observer) => {
this.clearOriginalCard();
})

不过我不知道这个 id-card 是啥,b 站动态创建的用户卡片?我没找到这个元素的位置,如果是的话那估计就要用观察者来解决竞争问题了,

biliscope/scripts/ui.js

Lines 345 to 349 in 5f4936b

UserProfileCard.prototype.clearOriginalCard = function() {
while (document.getElementById("id-card")) {
document.getElementById("id-card").remove();
}

@gaogaotiantian
Copy link
Owner Author

这肯定都是之前出现过的东西。在不产生性能瓶颈的情况下,可以暂时不动它。理论上确实不需要observe了。observe这个部分越来越复杂了,因为出现了太多的shadowtree,有机会我把它们稍微重构一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants