From efffac5b639515b69f7b4fc4aae8af48d5676edb Mon Sep 17 00:00:00 2001 From: iamsirsammy <77844774+iamsirsammy@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:30:21 -0400 Subject: [PATCH 1/2] change youtube/index.mjs to not confuse chatgpt or run out of tokens --- src/content-script/site-adapters/youtube/index.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/content-script/site-adapters/youtube/index.mjs b/src/content-script/site-adapters/youtube/index.mjs index 28b4f14a..f0b3fc61 100644 --- a/src/content-script/site-adapters/youtube/index.mjs +++ b/src/content-script/site-adapters/youtube/index.mjs @@ -1,6 +1,11 @@ import { cropText } from '../../../utils' import { config } from '../index.mjs' +function replaceHtmlEntities(htmlString) { // This function was written by ChatGPT and modified by me (iamsirsammy) + const doc = new DOMParser().parseFromString(htmlString.replace("&", "&"), 'text/html'); + return doc.documentElement.innerText; +} + export default { init: async (hostname, userConfig, getInput, mountComponent) => { try { @@ -44,9 +49,11 @@ export default { subtitleContent += subtitleData.substring(0, subtitleData.indexOf('<')) + ',' } + subtitleContent = replaceHtmlEntities(subtitleContent.replace(",", " ")) + return cropText( - `Provide a brief summary of the video using concise language and incorporating the video title.` + - `The video title is:"${title}".The subtitle content is as follows:\n${subtitleContent}`, + `Provide a brief summary of the following video using concise language, still including all the important details, and incorporating the video title.` + + `The video title is "${title}". The subtitle content is as follows:\n${subtitleContent}`, ) } catch (e) { console.log(e) From 342e5dda2f4f0f07fe41f54bb8280b00b14141cb Mon Sep 17 00:00:00 2001 From: iamsirsammy <77844774+iamsirsammy@users.noreply.github.com> Date: Thu, 13 Apr 2023 20:55:27 -0400 Subject: [PATCH 2/2] Update index.mjs --- src/content-script/site-adapters/youtube/index.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content-script/site-adapters/youtube/index.mjs b/src/content-script/site-adapters/youtube/index.mjs index f0b3fc61..435a1191 100644 --- a/src/content-script/site-adapters/youtube/index.mjs +++ b/src/content-script/site-adapters/youtube/index.mjs @@ -46,10 +46,10 @@ export default { let subtitleContent = '' while (subtitleData.indexOf('">') !== -1) { subtitleData = subtitleData.substring(subtitleData.indexOf('">') + 2) - subtitleContent += subtitleData.substring(0, subtitleData.indexOf('<')) + ',' + subtitleContent += subtitleData.substring(0, subtitleData.indexOf('<')) + ' ' } - subtitleContent = replaceHtmlEntities(subtitleContent.replace(",", " ")) + subtitleContent = replaceHtmlEntities(subtitleContent) return cropText( `Provide a brief summary of the following video using concise language, still including all the important details, and incorporating the video title.` +