Copy access token of ChatGPT

Add a button to copy the access token in the session page of ChatGPT

As of 2023-08-01. See the latest version.

// ==UserScript==
// @name         Copy access token of ChatGPT
// @namespace    https://flosacca.com/
// @version      1.0
// @description  Add a button to copy the access token in the session page of ChatGPT
// @author       flosacca
// @license      The Unlicense
// @match        https://chat.openai.com/api/auth/session
// @grant        none
// ==/UserScript==

(() => {
  const pre = document.querySelector('pre')
  const { accessToken } = JSON.parse(pre.textContent)
  const btn = document.createElement('button')
  btn.textContent = 'Copy access token'
  btn.onclick = () => {
    navigator.clipboard.writeText(accessToken)
  }
  pre.insertAdjacentElement('beforebegin', btn)
})()
长期地址
遇到问题?请前往 GitHub 提 Issues。