BiliBili 連結復原

新版bilibili把連結嵌入屬性,導致無法右/中鍵直接開啟😡

  1. // ==UserScript==
  2. // @name BiliBili 連結復原
  3. // @namespace Anong0u0
  4. // @version 0.1.5
  5. // @description 新版bilibili把連結嵌入屬性,導致無法右/中鍵直接開啟😡
  6. // @author Anong0u0
  7. // @match https://www.bilibili.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  9. // @require https://cdn.jsdelivr.net/npm/arrive@2.4.1/minified/arrive.min.js
  10. // @grant none
  11. // @run-at document-start
  12. // @license beerware
  13. // ==/UserScript==
  14.  
  15. Node.prototype.changeTag = function (tag)
  16. {
  17. const clone = document.createElement(tag)
  18. for (const attr of this.attributes) clone.setAttributeNS(null, attr.name, attr.value)
  19. while (this.firstChild) clone.appendChild(this.firstChild)
  20. this.replaceWith(clone)
  21. return clone
  22. }
  23.  
  24. document.arrive("a[data-url]", (e) =>
  25. {
  26. const link = e.getAttribute("data-url").match(/(?<=keyword=)[^&]+/)
  27. e.href = link ? `https://search.bilibili.com/all?keyword=${link}` : e.getAttribute("data-url")
  28. e.target = "_blank"
  29. })
  30.  
  31. document.arrive("a[data-user-id]", (e) =>
  32. {
  33. e.href = `https://space.bilibili.com/${e.getAttribute("data-user-id")}`
  34. e.target = "_blank"
  35. })
  36.  
  37. document.arrive("div[data-user-id]", (e) =>
  38. {
  39. e.changeTag("a")
  40. e.href = `https://space.bilibili.com/${e.getAttribute("data-user-id")}`
  41. e.target = "_blank"
  42. })
  43.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址