From e945e447558bb3a322516103c58dc509163e687a Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Mon, 1 May 2023 13:25:02 -0700 Subject: [PATCH] Display card on video page --- manifest.json | 2 +- scripts/biliscope.js | 8 ++------ scripts/ui.js | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index e2d0c0a..d7ae9e0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "BiliScope", - "version": "0.2.0", + "version": "0.2.1", "description": "Bilibili插件,知道TA是个什么UP主", "icons": { "128": "img/logo.png" diff --git a/scripts/biliscope.js b/scripts/biliscope.js index f1d8079..45a5d66 100644 --- a/scripts/biliscope.js +++ b/scripts/biliscope.js @@ -55,12 +55,8 @@ function getTarget(target) { } } } else { - for (let userLink of [target, target.parentNode]) { - if (userLink.tagName == "A" && userLink.href.startsWith(BILIBILI_SPACE_URL)) { - if (userLink.hasAttribute("report-id")) { - // Video page, the uploader name link, avoid overlap - return null; - } + for (let userLink of [target, target.parentNode, target.parentNode.parentNode]) { + if (userLink && userLink.tagName == "A" && userLink.href.startsWith(BILIBILI_SPACE_URL)) { return userLink; } } diff --git a/scripts/ui.js b/scripts/ui.js index 97a815c..d98da1b 100644 --- a/scripts/ui.js +++ b/scripts/ui.js @@ -160,7 +160,6 @@ function UserProfileCard() { this.target = null; this.enabled = false; this.wordCloud = null; - this.lastDisable = 0; this.el = document.createElement("div"); this.el.style.position = "absolute"; this.el.style.display = "none"; @@ -194,7 +193,7 @@ UserProfileCard.prototype.disable = function() { } UserProfileCard.prototype.enable = function() { - if (!this.enabled && Date.now() - this.lastDisable > 50) { + if (!this.enabled) { this.enabled = true; this.idCardObserver.observe(document.body, { "childList": true, @@ -267,7 +266,6 @@ UserProfileCard.prototype.updateTarget = function(target) { upc = this this.target.addEventListener("mouseleave", function leaveHandle(ev) { upc.disable(); - upc.lastDisable = Date.now(); this.removeEventListener("mouseleave", leaveHandle); }) }