Last active
May 14, 2023 02:55
-
-
Save chunpu/7ddce4881af48b98ace2b369dc47c03c to your computer and use it in GitHub Desktop.
ChatGPT Long Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!(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