Updating Plans Now Does Things
also summaries for yt comments

Updating Plans Now Does Things
0:00
/320.469333





fig 3
if (tab.url.includes('youtube.com')) {
async function extractTranscript() {
// close cookie banner if exists
document.querySelector('button[aria-label*=cookies]')?.click();
// click the "show transcript" button
const transcriptBtn = document.querySelector('ytd-video-description-transcript-section-renderer button');
if (!transcriptBtn) {
console.log('no transcript button found');
return;
}
transcriptBtn.click();
// wait for transcript container to appear (adjust time as needed)
await new Promise(resolve => setTimeout(resolve, 3000));
// scrape transcript text
const transcriptNodes = Array.from(document.querySelectorAll('#segments-container yt-formatted-string'));
const transcriptText = transcriptNodes.map(node => node.textContent.trim()).join('\n');
// send transcript back to background (if needed)
chrome.runtime.sendMessage({ action: 'transcriptScraped', transcript: transcriptText });
const channelElement = document.querySelector('ytd-channel-name');
const channelName = channelElement?.textContent.trim().split('\n')[0];
return {
transcript: transcriptText,
channelName: channelName,
};
}
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: extractTranscript,
}, async (transcript) => {
if (chrome.runtime.lastError) {
console.error('Script injection failed: ', chrome.runtime.lastError);
return;
}
if (!transcript[0].result.transcript) {
console.log('No transcript found');
return;
}
console.log('transcript:', transcript);
const openaiRes = await callOpenAI(openAIAPIKey, transcript[0].result.transcript, `You are a helpful assistant. You will be given a transcript of a video. Your task is to summarize the transcript in a concise and informative manner. Please ensure that the summary is accurate and relevant to the content of the video. Do not include any additional information or explanations. You are a glorified summarizer/teleprompter, so stay on topic. Use the channel name where appropriate, because it is the creators video. Channel name: ${transcript[0].result.channelName}`);
console.log('transcript extracted');
console.log('openaiRes:', openaiRes.choices[0].message.content);
proceedWithPostRequestWithComment(
tabTitle,
tabUrl,
`${tabTitle} | ${transcript[0].result.channelName}`,
tabUrl,
openaiRes.choices[0].message.content
);
});