chatgpt-page-summary-button

🍓 let ChatGPT summary the web page you are reading in one click

< Feedback on chatgpt-page-summary-button

Review: Good - script works

The script adds a pink button to the right side of any page. When hovering over the button it flys out and says "Page Summary." However, when you click it, then nothing happens. I might try to fix the script, but it looks like something is not working right. It doesn't send your text to ChatGPT.

Actually, it does work. When you click the button, it will copy all the text from the current page and pastes it into the ChatGPT prompt in chunks. Then summarize it with bullet points. Great script!!

mefenglAuthor
§
Posted: 2023-10-27

Thanks, glad to know this script helps others too.

@mefengi, I'd like to fork the script and make a couple small changes such as the ability to select and send to chatgpt. Would you mind? Let me know if it's okay for me to fork and expand on some of the features. Thank you.

mefenglAuthor
§
Posted: 2023-10-29

Of course, you're very welcome to fork and make improvements to the script! The code is distributed under the MIT license, so you're free to modify it.

  1. Source code is located at: https://github.com/mefengl/chat-play/tree/main/apps/page-buttons/page-summary-button
  2. If you have any questions or concerns, you can reach me at https://github.com/mefengl/chat-play/discussions or directly here.

Thank you for your interest!

mefenglAuthor
§
Posted: 2023-11-14

Ah, so it turns out we have already communicated before😉.

I'm not very good at JavaScript and don't understand Typescript. I mean to eventually learn. So when I looked at your repo, I had difficulty understanding how to fork it and contribute. Maybe I can just tell you what I changed and share the code as a gist?

Under your initialze function I put a functon to get selected text. When the user selects text in a page, then they may only want to summarize the portion they selected rather than the entire page.

function getSelectedText() {
    if (window.getSelection) {
        return window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        return document.selection.createRange().text;
    }
    return '';
}

I changed your prompt. I like that your prompt adds multiple emojis but for me, it was easier to read when only major headings used emojis. Here is the new prompt:

Could you please summarize the provided text into a concise bulleted list. Prefix major headings with a 📌 emoji and below that list the key points or main ideas:

I added a menu for selected text as well:

GM_registerMenuCommand("\u{1F4DD} Input", () => {
    const selectedText = getSelectedText();
    if (selectedText) {
        setPrompts([selectedText]);
    } else {
        import_sweetalert22.default.fire({
            title: "Please input the text you want to deal with",
            input: "textarea",
            inputPlaceholder: "Enter your text here"
        }).then((result) => {
            if (result.value)
                setPrompts(new SimpleArticleSegmentation(result.value).segment());
        });
    }
});

I haven't tested my version because I know your old one relied on "sweetalert2" and now "sweetalert3" but I think it still works.

Also modified the callback function of the button so it uses only selected text when user has text selected:

createButton_default(() => __async(void 0, null, function* () {
  const selectedText = getSelectedText();
  if (selectedText) {
    setPrompts([selectedText]);
  } else {
    setPrompts(getParagraphs());
  }
}), navigator.language.startsWith("zh") ? "\u9875\u9762\u6458\u8981" : "Page Summary");

Lastly, I didn't agree with the semantic verion number format you used e.g., 0.8.0 originally. Now you are on 0.9.10. I changed it to 1.0.1 and now 1.1.0 because this is a fairly large change to the code IMHO.

Let me know what you think. Thank you for creating the script!!!

Lastly, I want to contact you offline because I want to make a userscript or Chrome Extension that can send text to ChatGPT. I want to create a spaced repetition app that allows users to create quizzes from Udemy courses. Then using spaced repetition, alert the user if they want to review the material, if yes, then send the quiz to ChatGPT to help grade the user's answers to the quiz. So, this is my idea and as I said, I'm not good at JavaScript but you are. Maybe we can work together on this project?

mefenglAuthor
§
Posted: 2024-03-04

👋

If you're on Twitter, DM me at https://x.com/mefengl. If you don't use Twitter, my Discord channel is https://discord.gg/pwTKpnc2sF, find me there and DM.

Post reply

Sign in to post a reply.