Keep ChatGPT Element Resizer & Repositioner

Enhances the usability of the Keep ChatGPT extension by resizing and repositioning its element above the search box on chatgpt.com.

  1. // ==UserScript==
  2. // @name Keep ChatGPT Element Resizer & Repositioner
  3. // @namespace https://greasyfork.org/en/users/567951-stuart-saddler
  4. // @version 1.0
  5. // @description Enhances the usability of the Keep ChatGPT extension by resizing and repositioning its element above the search box on chatgpt.com.
  6. // @author Stuart Saddler
  7. // @match https://chatgpt.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to adjust and reposition the element
  16. function adjustElement() {
  17. const element = document.getElementById('kcg');
  18. const appElement = document.getElementById('App');
  19.  
  20. if (element) {
  21. // Move the kcg element above the App element
  22. if (appElement && appElement.parentNode && appElement.previousSibling !== element) {
  23. appElement.parentNode.insertBefore(element, appElement);
  24. }
  25.  
  26. // Resize and align the element
  27. element.style.width = '25px'; // Adjust the width
  28. element.style.height = '25px'; // Reduce height by half
  29. element.style.fontSize = '12px'; // Adjust font size
  30. element.style.padding = '5px'; // Adjust padding
  31. element.style.margin = '5px 0'; // Remove horizontal centering
  32. element.style.textAlign = 'left'; // Ensure content is left-aligned
  33.  
  34. // Remove the element text
  35. const unwantedText = Array.from(element.childNodes).find(
  36. (node) => node.nodeType === Node.TEXT_NODE && node.textContent.includes('by xcanwin')
  37. );
  38. if (unwantedText) {
  39. element.removeChild(unwantedText);
  40. }
  41. }
  42. }
  43.  
  44. // Apply adjustments on page load
  45. window.addEventListener('load', adjustElement);
  46.  
  47. // Observe dynamic changes to the DOM
  48. const observer = new MutationObserver(() => {
  49. adjustElement();
  50. });
  51.  
  52. observer.observe(document.body, { childList: true, subtree: true });
  53.  
  54. // Periodic fallback for additional enforcement
  55. setInterval(() => {
  56. adjustElement();
  57. }, 1000);
  58. })();