ChatGPT 折叠自己消息和最大宽度

折叠ChatGPT中较长的“你”消息,并设置最大宽度

目前为 2024-08-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name ChatGPT Chat Fold Script & MAXWidth
  3. // @name:en ChatGPT Chat Fold Script & MAXWidth
  4. // @name:zh-CN ChatGPT 折叠自己消息和最大宽度
  5. // @name:zh-TW ChatGPT 摺疊自己消息和最大寬度
  6. // @name:ja ChatGPT チャット折りたたみスクリプトと最大幅
  7. // @name:vi ChatGPT Gấp Lại Tin Nhắn và Đặt Chiều Rộng Tối Đa
  8. // @description Fold long "You" messages in ChatGPT
  9. // @description:en Fold long "You" messages in ChatGPT
  10. // @description:zh-CN 折叠ChatGPT中较长的“你”消息,并设置最大宽度
  11. // @description:zh-TW 摺疊ChatGPT中較長的“你”訊息,並設置最大寬度
  12. // @description:ja ChatGPTで長い「あなた」のメッセージを折りたたみ、最大幅を設定します
  13. // @description:vi Gấp lại các tin nhắn "Bạn" dài trong ChatGPT và thiết lập chiều rộng tối đa
  14. // @namespace https://github.com/ChinaGodMan/UserScripts
  15. // @version 0.1
  16. // @author 人民的勤务员 <toniaiwanowskiskr47@gmail.com>
  17. // @match https://chatgpt.com/*
  18. // @match https://share.nezhagpt.cloud/*
  19. // @match https://new.oaifree.com/*
  20. // @grant none
  21. // @license MIT
  22. // @supportURL https://github.com/ChinaGodMan/UserScripts/issues
  23. // @homepageURL https://github.com/ChinaGodMan/UserScripts
  24. // ==/UserScript==
  25.  
  26. (function () {
  27. 'use strict'
  28. //MAX WIGHT
  29. let css = `
  30. .md\\:max-w-3xl {
  31. max-width: 100%;
  32. }
  33. `
  34. if (typeof GM_addStyle !== "undefined") {
  35. GM_addStyle(css)//// homepageURL https://gitlab.com/breatfr/chatgpt-responsive
  36. // https://discord.gg/Q8KSHzdBxs
  37. } else {
  38. let styleNode = document.createElement("style")
  39. styleNode.appendChild(document.createTextNode(css));
  40. (document.querySelector("head") || document.documentElement).appendChild(styleNode)
  41. }
  42. // Your code here...
  43. window.addEventListener('load', function () {
  44. // Function to fold long messages
  45. function foldLongMessages() {
  46. const messages = document.querySelectorAll('div[data-message-author-role="user"]')
  47.  
  48. messages.forEach(message => {
  49. if (message.innerText.split('\n').length > 3) {
  50. message.style.overflow = 'hidden'
  51. message.style.height = '100px' // Adjust as needed
  52. message.style.cursor = 'pointer'
  53.  
  54. // Click to expand
  55. message.addEventListener('click', function () {
  56. if (message.style.overflow === 'hidden') {
  57. message.style.overflow = 'visible'
  58. message.style.height = 'auto'
  59. } else {
  60. message.style.overflow = 'hidden'
  61. message.style.height = '100px'
  62. }
  63. })
  64. }
  65. })
  66. }
  67.  
  68. // Run the function and also set an interval to handle dynamic content
  69. foldLongMessages()
  70. setInterval(foldLongMessages, 1000)
  71. })
  72. })()

QingJ © 2025

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