/** * A custom script for the Platypush browser extension that simplifies the * current page by extracting the main content and displaying it in a clean * format. * * This script uses the Mercury parser to extract the main content of the page * and formats it for better readability. * * The parsed content will be added inside a new
element with a * simplified style, and the previous page content will be hidden. * * (c) 2025 Fabio Manganiello * @license GNU General Public License v3.0 */ // Entry point for the script. All the logic should be placed inside this function. async (app, args) => { // Get the current URL and DOM of the page. const url = await app.getURL(); const dom = await app.getDOM(); const html = dom.body.innerHTML; // Parse the page content using the Mercury parser API. const response = await app.mercury.parse(url, html); // Custom style for the simplified content. // This uses a light style - you can modify it to suit your needs. const style = ` `; // Create a new simplified div with the parsed content. // .platypush__simplified-body contains the main content, // .platypush__original-body contains the original (hidden) page content. // An anchor link is provided to return to the original page content. const simplifiedDiv = `

${response.title}

${response.content}
${dom.body.innerHTML}
`; // Add the custom style and the simplified content to the DOM. dom.head.innerHTML += style; dom.body.innerHTML = simplifiedDiv; // Set the modified DOM back to the app. await app.setDOM(`${dom.getElementsByTagName('html')[0].innerHTML}`); }