Skip to content

Instantly share code, notes, and snippets.

@chunpu
Last active May 14, 2023 02:55
Show Gist options
  • Save chunpu/7ddce4881af48b98ace2b369dc47c03c to your computer and use it in GitHub Desktop.
Save chunpu/7ddce4881af48b98ace2b369dc47c03c to your computer and use it in GitHub Desktop.
ChatGPT Long Text
!(function () {
// ai.com console input
// 使用方法 q(`long text`)
var $ = function (val) {
return document.querySelector(val)
}
window.q = q
async function q(longStr) {
var sendIndex = 0
var maxOnce = 300 // 每次最多300个中文
while (sendIndex * maxOnce < longStr.length) {
var rawStr = longStr.slice(
sendIndex * maxOnce,
sendIndex * maxOnce + maxOnce
)
var currentStr = rawStr
// 反复强化记忆
currentStr =
'我正在分段给你输入一段长文本,在输入结束前你只需要回答"收到":\n' +
currentStr
// 反复强化记忆
currentStr += '\n还没结束,你只需要回复"收到"'
console.log(`第${sendIndex + 1}次发送`, rawStr)
await send(currentStr)
sendIndex++
}
alert('输入结束')
}
function send(str) {
$('textarea').focus()
document.execCommand('insertText', false, str)
$('form button.absolute').click()
return new Promise((resolve) => {
var timer = setInterval(() => {
if (!isLoading()) {
clearInterval(timer)
resolve()
}
}, 3000)
})
}
function isLoading() {
var sendButtonSvg = $('form button.absolute svg')
return sendButtonSvg == null
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment