ChatGPT ReadMode Alt+R

5/29/2023, 10:32:31 AM

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        ChatGPT ReadMode Alt+R
// @namespace   Violentmonkey Scripts
// @match       https://chat.openai.com/c/*
// @grant       none
// @version     1.0
// @author      -
// @description 5/29/2023, 10:32:31 AM
// @license MIT
// ==/UserScript==

let readMode = false
let sidebar, chatPane, formBlock

waitFor(isMainPresent).then(assignListener)

function waitFor(predicateFn) {
  return new Promise(resolve => {
    setTimeout(() => {
      const result = predicateFn()
      if (result) resolve(result)
      else waitFor(predicateFn).then(resolve)
    })
  })
}

function isMainPresent() {
  return document.querySelector('.w-full.h-full')
}

function assignListener(main) {
  [sideBar, chatPane] = main.children

  addEventListener('keydown', e => {
    if (e.key == 'r' && e.altKey) toggleReadMode()
  })
}

function toggleReadMode() {
  formBlock = chatPane.querySelector('.absolute.bottom-0')
  readMode = !readMode

  document.documentElement.style.fontSize = readMode ? '24px' : null
  sideBar.hidden = readMode
  if (formBlock) formBlock.hidden = readMode
}