巴哈姆特 Now!樣式修改

修改Now的樣式,讓他在網頁版從無法直視變得勉強可看

  1. // ==UserScript==
  2. // @name 巴哈姆特 Now!樣式修改
  3. // @description 修改Now的樣式,讓他在網頁版從無法直視變得勉強可看
  4. // @namespace nathan60107
  5. // @author nathan60107(貝果)
  6. // @version 1.2.4
  7. // @homepage https://home.gamer.com.tw/profile/index_creation.php?owner=nathan60107&folder=425332
  8. // @match https://forum.gamer.com.tw/B.php*
  9. // @match https://now.gamer.com.tw/chat_list.php*
  10. // @icon https://ani.gamer.com.tw/apple-touch-icon-144.jpg
  11. // @require https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js
  12. // @grant GM_addStyle
  13. // @noframes
  14. // ==/UserScript==
  15.  
  16. GM_addStyle(`
  17. .now_chatroom-container .chatroom .msg_container {
  18. margin-top: 12px !important;
  19. margin-bottom: 12px !important;
  20. }
  21. .now_chatroom-container.is-bpage {
  22. height: 90vh !important;
  23. }
  24. div[class^="user-runes runes_lv"] {
  25. display: none !important;
  26. }
  27. .chatroom {
  28. overscroll-behavior: contain;
  29. }
  30. `)
  31.  
  32. function handleLayout() {
  33. const elements = document.querySelectorAll(".msg_container")
  34.  
  35. for (let i = 0; i < elements.length - 1; i++) {
  36. const current = elements[i]
  37. const next = elements[i + 1]
  38.  
  39. // 如果當前元素和下一個元素的 data-uid 相同
  40. if (current.dataset.uid === next.dataset.uid) {
  41. // 從下一個開始處理
  42. for (
  43. let j = i + 1;
  44. j < elements.length && elements[j].dataset.uid === current.dataset.uid;
  45. j++
  46. ) {
  47. // 尋找 j 之下的 .now_user-info 並設置 display: none
  48. const nowUserInfo = elements[j].querySelector(".now_user-info")
  49. if (nowUserInfo) {
  50. nowUserInfo.style.display = "none"
  51. }
  52.  
  53. // 尋找 j 之下的 .user-headshot 並設置 visibility: hidden
  54. const userHeadshot = elements[j].querySelector(".user-headshot")
  55. if (userHeadshot) {
  56. userHeadshot.style.visibility = "hidden"
  57. userHeadshot.style.height = 0
  58. }
  59. }
  60. }
  61. }
  62. }
  63.  
  64. ;(async function () {
  65. const observer = new MutationObserver(handleLayout)
  66.  
  67. observer.observe(
  68. document.querySelector("#BH-slave, .now_chatroom-container"),
  69. { childList: true, subtree: true }
  70. )
  71.  
  72. document.addEventListener("focus", function () {
  73. if (document.hidden) return
  74. document.getElementById("msg_input")?.focus()
  75. })
  76. })()
  77.  
  78. /* Ref:
  79. * https://stackoverflow.com/a/19392142
  80. */

QingJ © 2025

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