Claude Content Max-Width

adjust Claude Content Max-Width

当前为 2024-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Claude Content Max-Width
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.9
  5. // @description adjust Claude Content Max-Width
  6. // @author shawn-wxn
  7. // @match https://claude.ai/*
  8. // @match https://poe.com/*
  9. // @match https://*.geeksmonkey.com/*
  10. // @match https://*.perplexity.ai/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=claude.ai
  12. // @grant GM_addStyle
  13. // @grant GM_log
  14. // @license GPL-2.0-only
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. // 获取当前的 URL
  19. var currentURL = window.location.href;
  20.  
  21. // 根据当前 URL 进行 if-else 逻辑判断
  22. if (currentURL.includes("poe.com")) {
  23. var inputFooter = document.querySelector("div[class^='ChatPageMainFooter_footerInner__']");
  24. var inputFooterClass = null;
  25. for (var className of inputFooter.classList){
  26. if (className.indexOf('ChatPageMainFooter_footerInner__') !== -1) {
  27. inputFooterClass = className;
  28. break;
  29. }
  30. }
  31. if (!inputFooterClass) {
  32. GM_log("ERROR: not found inputFooterClass.");
  33. }
  34.  
  35. var chatPageMainDiv = document.querySelector("div[class^='InfiniteScroll_container__']");
  36. var chatPageMainDivClass = null;
  37. for (className of chatPageMainDiv.classList){
  38. if (className.indexOf('InfiniteScroll_container__') !== -1) {
  39. chatPageMainDivClass = className;
  40. break;
  41. }
  42. }
  43. if (!chatPageMainDivClass) {
  44. GM_log("ERROR: not found chatPageMainDivClass.");
  45. }
  46.  
  47. var humanMessageDiv = document.querySelector("div[class^='Message_humanMessageBubble__']");
  48. var humanMessageDivClass = null;
  49. for (className of humanMessageDiv.classList){
  50. if (className.indexOf('Message_humanMessageBubble__') !== -1) {
  51. humanMessageDivClass = className;
  52. break;
  53. }
  54. }
  55. if (!humanMessageDivClass) {
  56. GM_log("ERROR: not found humanMessageDivClass.");
  57. }
  58.  
  59. var botMessageDiv = document.querySelector("div[class^='Message_botMessageBubble__']");
  60. var botMessageDivClass = null;
  61. for (className of botMessageDiv.classList){
  62. if (className.indexOf('Message_botMessageBubble__') !== -1) {
  63. botMessageDivClass = className;
  64. break;
  65. }
  66. }
  67. if (!botMessageDivClass) {
  68. GM_log("ERROR: not found botMessageDivClass.");
  69. }
  70.  
  71. GM_addStyle(`
  72. .${inputFooterClass} {
  73. --desktop-reading-column-max-width: ${Math.floor(window.innerWidth * 0.048)}rem;
  74. }
  75. .${chatPageMainDivClass} {
  76. --desktop-reading-column-max-width: ${Math.floor(window.innerWidth * 0.048)}rem;
  77. }
  78. .${humanMessageDivClass} {
  79. max-width: ${Math.floor(window.innerWidth * 0.078)}ch;
  80. }
  81. .${botMessageDivClass} {
  82. max-width: ${Math.floor(window.innerWidth * 0.078)}ch;
  83. }`
  84. )
  85. } else if (currentURL.includes("claude.ai")) {
  86. // 创建一个<style>标签
  87. var styleTag = document.createElement('style');
  88.  
  89. // 将 CSS 样式添加到<style>标签中
  90. var cssStyles = `
  91. /* 在这里添加您的 CSS 样式 */
  92. .max-w-3xl {
  93. max-width: ${Math.floor(window.innerWidth * 0.05)}rem;
  94. }
  95. .max-w-\\[75ch\\] {
  96. max-width: ${Math.floor(window.innerWidth * 0.1)}ch;
  97. }
  98. .max-w-\\[60ch\\] {
  99. max-width: ${Math.floor(window.innerWidth * 0.1)}ch;
  100. }
  101. `;
  102.  
  103. // 设置<style>标签的内容为 CSS 样式
  104. styleTag.innerHTML = cssStyles;
  105.  
  106. // 将<style>标签添加到<head>标签中
  107. document.head.appendChild(styleTag);
  108. } else if (currentURL.includes("geeksmonkey.com")){
  109. // 选择目标节点
  110. const targetNode = document.getElementById('app');
  111.  
  112. // 创建一个观察器实例并传入回调函数
  113. const observer = new MutationObserver(function(mutations) {
  114. // 遍历所有的变动记录
  115. mutations.forEach(function(mutation) {
  116. // 检查是否有子节点被移除
  117. if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {
  118. // 遍历所有被移除的节点
  119. for (let i = 0; i < mutation.removedNodes.length; i++) {
  120. // 检查这个节点是否是我们关注的节点(具有class=load-wrapper)
  121. const node = mutation.removedNodes[i];
  122. if (node.nodeType === Node.ELEMENT_NODE){
  123. if (node.classList.contains('loading-wrap')) {
  124. // 动画结束,load-wrapper元素被移除
  125. // 在这里执行你想要进行的操作
  126. var imageWraperDiv = document.getElementById("image-wrapper");
  127. var imageWraperDivClass = null;
  128. for (className of imageWraperDiv.classList) {
  129. if (className.indexOf('max-w-screen-xl') !== -1) {
  130. imageWraperDivClass = className;
  131. break;
  132. }
  133. }
  134. if (!imageWraperDivClass) {
  135. GM_log("ERROR: not found imageWraperDivClass.");
  136. }
  137.  
  138. GM_addStyle(`
  139. .${imageWraperDivClass} {
  140. max-width: ${Math.floor(window.innerWidth * 0.83)}px;
  141. }`
  142. )
  143.  
  144. // 一旦检测到load-wrapper元素被移除,就断开观察器
  145. observer.disconnect();
  146. return; // 退出循环和回调函数
  147. }
  148. }
  149. }
  150. }
  151. });
  152. });
  153.  
  154. // 配置观察选项:
  155. const config = { attributes: false, childList: true, subtree: true };
  156.  
  157. // 传入目标节点和观察选项开始观察
  158. observer.observe(targetNode, config);
  159.  
  160.  
  161. } else if (currentURL.includes("perplexity.ai")){
  162. // 创建一个<style>标签
  163. var styleTag = document.createElement('style');
  164.  
  165. // 将 CSS 样式添加到<style>标签中
  166. var cssStyles = `
  167. /* 在这里添加您的 CSS 样式 */
  168. .max-w-threadWidth {
  169. max-width: ${Math.floor(window.innerWidth * 0.85)}px;
  170. }
  171. `;
  172.  
  173. // 设置<style>标签的内容为 CSS 样式
  174. styleTag.innerHTML = cssStyles;
  175.  
  176. // 将<style>标签添加到<head>标签中
  177. document.head.appendChild(styleTag);
  178. } else {
  179. // 如果以上条件都不满足
  180. console.log("当前 URL 不符合预期");
  181. }
  182. })();

QingJ © 2025

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