您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a button to copy the access token in the session page of ChatGPT, for the JSON viewer of Google Chrome
// ==UserScript== // @name Copy access token of ChatGPT // @namespace https://flosacca.com/ // @version 1.1 // @description Add a button to copy the access token in the session page of ChatGPT, for the JSON viewer of Google Chrome // @author flosacca // @license The Unlicense // @match https://chat.openai.com/api/auth/session // @grant none // ==/UserScript== (() => { if (navigator.vendor !== 'Google Inc.') { return } 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) const fixed = document.querySelector('.json-formatter-container') if (!fixed) { return } const css = (el, name) => getComputedStyle(el).getPropertyValue(name) const len0 = css(fixed, 'height') const len1 = css(pre, 'padding-top') const len2 = css(btn, 'height') const len3 = `calc(${len0} + ${css(pre, 'margin-top')})` const div = document.createElement('div') div.style = `height: calc(${len3} + ${len2} - ${len1});` btn.style = `position: absolute; top: ${len3};` btn.replaceWith(div) div.append(btn) })()