Expand-Gpt

Expand the width of the page

  1. // ==UserScript==
  2. // @name Expand-Gpt
  3. // @namespace https://github.com/neokyuubi/expand-chatgpt
  4. // @version 0.1.3
  5. // @description Expand the width of the page
  6. // @author Neokyuubi
  7. // @match https://chat.openai.com/*
  8. // @match https://chatgpt.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  10. // @grant none
  11. // @require https://code.jquery.com/jquery-3.6.0.min.js
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to update max-width of elements
  18. function updateMaxWidth() {
  19. document.querySelectorAll('[class*="xl:max-w-[48rem]"], [class*="lg:max-w-[40rem]"]').forEach(el => el.style.maxWidth = '100%');
  20. document.querySelectorAll('[class*="max-w-[90%]"]').forEach(el => el.style.width = '100%');
  21. document.querySelectorAll('[class*="max-w-[70%]"]').forEach(el => {
  22. el.style.maxWidth = '97%';
  23. el.style.border = '2px dashed';
  24. });
  25. }
  26.  
  27. // Initial update
  28. updateMaxWidth();
  29.  
  30. // Create a MutationObserver to watch for added nodes
  31. const observer = new MutationObserver((mutationsList) => {
  32. let needsUpdate = false;
  33. for (const mutation of mutationsList) {
  34. if (mutation.type === 'childList') {
  35. for (const node of mutation.addedNodes) {
  36. if (node.nodeType === 1) { // Ensure it's an element node
  37. if (node.matches('[class*="xl:max-w-[48rem]"], [class*="max-w-[90%]"], [class*="max-w-[70%]"], [class*="lg:max-w-[40rem]') ||
  38. node.querySelector('[class*="xl:max-w-[48rem]"], [class*="max-w-[90%]"], [class*="max-w-[70%]"], [class*="lg:max-w-[40rem]')) {
  39. needsUpdate = true;
  40. break;
  41. }
  42. }
  43. }
  44. }
  45. if (needsUpdate) break;
  46. }
  47. if (needsUpdate) updateMaxWidth();
  48. });
  49.  
  50. // Start observing the document body for added nodes
  51. observer.observe(document.body, { childList: true, subtree: true });
  52.  
  53. })();

QingJ © 2025

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