publink-openai-beautify

openai样式美化

  1. // ==UserScript==
  2. // @name publink-openai-beautify
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.01
  5. // @description openai样式美化
  6. // @author huangbc
  7. // @include *://*
  8. // @license MIT
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=shb.ltd
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let styleElement = document.createElement('style')
  17. styleElement.textContent = `nav > a.items-center:nth-of-type(2) { display: none; }`
  18.  
  19. let scriptElement = document.createElement('script')
  20. scriptElement.textContent = `
  21. function setTextareaHeight() {
  22.  
  23. let isOpenAI = window.location.host == "chat.openai.com"
  24.  
  25. if (!isOpenAI) {
  26. return;
  27. }
  28.  
  29. let textElement = document.querySelector('textarea');
  30.  
  31. textElement.addEventListener('focus', function(event) {
  32.  
  33. const element = event.target;
  34. element.style.minHeight = '200px';
  35.  
  36. })
  37.  
  38. textElement.addEventListener('blur', function() {
  39. const element = event.target;
  40. element.style.minHeight = '0px';
  41. })
  42. }
  43.  
  44. window.onload = () => {
  45. setTimeout(() => {
  46. setTextareaHeight();
  47. }, 2000);
  48. }
  49.  
  50. `
  51. // document.body.append(scriptElement)
  52. document.body.append(styleElement)
  53.  
  54. // Your code here...
  55. })();