Add Pre-generated summaries & delivery mechanism
-
Adds 10,000 demo summaries, i.e the first section of selected Wikipedia articles, concatenated to 100 words.
-
Adds a content script that reads the files and returns the summary text via a window.postMessage dispatcher.
This summaryDispatcher.js script is executed in the default 'isolated' context so that it has access to extension-specific files, but window.postMessage provides a way for it to communicate with the 'main' page content scripts.
The postMessage handler can be tested from the console:
// add a listener to capture responses
window.addEventListener( 'message', ( message ) => {
if ( message.data.action === 'SUMMARY_RESPONSE' ) {
console.log( 'got the summary:', message.data.content );
}
} );
// send requests for summaries based on title
window.postMessage( { action: 'SUMMARY_REQUEST', title: 'Cleopatra' } );
window.postMessage( { action: 'SUMMARY_REQUEST', title: 'Andes' } );
Bug: T376913