-
-
Save SanariSan/4cb90c79db9be1297ba97fb92bfc498b to your computer and use it in GitHub Desktop.
Bookmark-let to summarize a web page using GPT-3 - written by GPT-3
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
javascript: (function () { | |
var text = document.body.innerText; | |
var spl = text.split(" "); | |
if (spl.length > 3000) { | |
text = spl.slice(0, 3000).join(" "); | |
} | |
fetch('https://api.openai.com/v1/completions', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
}, | |
body: JSON.stringify({ | |
"model": "text-davinci-003", | |
"prompt": "Summarize this page " + text, | |
"temperature": 0.7, | |
"max_tokens": 500, | |
"top_p": 1, | |
"frequency_penalty": 0, | |
"presence_penalty": 0 | |
}) | |
}).then(res => res.json()).then(data => { | |
const summary = data.choices[0].text; | |
const banner = document.createElement('div'); | |
banner.style.position = 'fixed'; | |
banner.style.left = '0'; | |
banner.style.right = '0'; | |
banner.style.top = '0'; | |
banner.style.zIndex = 999999999; | |
banner.style.background = '#000'; | |
banner.style.color = '#fff'; | |
banner.style.padding = '15px'; | |
banner.innerHTML = summary; | |
document.body.appendChild(banner); | |
}); | |
})(); | |
// Or use the minified version | |
javascript:(function(){var text=document.body.innerText;var spl=text.split(" ");if (spl.length > 3000) {text=spl.slice(0,3000).join(" ");} fetch('https://api.openai.com/v1/completions',{method:'POST',headers:{'Content-Type':'application/json','Authorization':'Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'},body:JSON.stringify({"model":"text-davinci-003","prompt":"Summarize this page " + text,"temperature":0.7,"max_tokens":500,"top_p":1,"frequency_penalty":0,"presence_penalty":0})}).then(res => res.json()).then(data => {const summary=data.choices[0].text;const banner=document.createElement('div');banner.style.position='fixed';banner.style.left='0';banner.style.right='0';banner.style.top='0';banner.style.zIndex=999999999;banner.style.background='#000';banner.style.color='#fff';banner.style.padding='15px';banner.innerHTML=summary;document.body.appendChild(banner);});})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment