ChatGPT / Gemini / Claude Width

increase chatgpt, gemini and claude box width

  1. // ==UserScript==
  2. // @name ChatGPT / Gemini / Claude Width
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.10
  5. // @description increase chatgpt, gemini and claude box width
  6. // @author bitmunja
  7. // @license MIT
  8. // @match https://gemini.google.com/*
  9. // @match https://chat.openai.com/*
  10. // @match https://chatgpt.com/*
  11. // @match https://claude.ai/chat/*
  12. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // Convenience function to execute your callback only after an element matching readySelector has been added to the page.
  20. function runWhenReady(readySelector, callback) {
  21. var numAttempts = 0;
  22. var tryNow = function() {
  23. var elem = document.querySelector(readySelector);
  24. if (elem) {
  25. callback(elem);
  26. } else {
  27. numAttempts++;
  28. if (numAttempts >= 34) {
  29. console.warn(`Width script: giving up after 34 attempts. Could not find: ${readySelector}`);
  30. } else {
  31. setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
  32. }
  33. }
  34. };
  35. tryNow();
  36. }
  37.  
  38. // Function to apply width adjustment to the elements returned by the getElementsCallback
  39. function applyWidth(getElementsCallback) {
  40. const elements = getElementsCallback();
  41. for (let i = 0; i < elements.length; i++) {
  42. elements[i].style.setProperty('max-width', '98%', 'important');
  43. }
  44. }
  45.  
  46. // Generic function to observe mutations and apply width adjustments
  47. function observeMutations(getElementsCallback) {
  48. const observer = new MutationObserver(function(mutations) {
  49. let eventRegistrationCount = 0;
  50. mutations.forEach(function(mutation) {
  51. if (mutation.type === 'childList') {
  52. eventRegistrationCount++;
  53. }
  54. });
  55. if(eventRegistrationCount > 0) {
  56. applyWidth(getElementsCallback);
  57. }
  58. });
  59. observer.observe(document.documentElement, { childList: true, subtree: true });
  60. }
  61.  
  62. // Check the domain and apply the corresponding logic
  63. const hostname = window.location.hostname;
  64.  
  65. if (hostname === 'chat.openai.com' || hostname === 'chatgpt.com') {
  66. const getElements = () => document.querySelectorAll('.text-base');
  67. runWhenReady('.text-base', function() {
  68. applyWidth(getElements);
  69. observeMutations(getElements);
  70. });
  71. } else if (hostname === 'gemini.google.com') {
  72. const getElements = () => document.querySelectorAll('.conversation-container');
  73. runWhenReady('.conversation-container', function() {
  74. applyWidth(getElements);
  75. observeMutations(getElements);
  76. });
  77. } else if (hostname === 'claude.ai') {
  78. const getElements = () => {
  79. const coreSelector = 'div[data-test-render-count]';
  80. const l1Element = document.querySelector(coreSelector).parentElement;
  81. const l2Element = l1Element.parentElement;
  82. return [l1Element, l2Element]
  83. }
  84. runWhenReady('div[data-is-streaming]', function() {
  85. applyWidth(getElements);
  86. observeMutations(getElements);
  87. });
  88. }
  89. })();

QingJ © 2025

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