create a chrome extension that scrapes the content of the current page when the user…
- User
create a chrome extension that scrapes the content of the current page when the user presses spacebar and appends the content to the clipboard
Assistant
Here is some sample code for a Chrome extension that scrapes the content of the current page when the user presses the spacebar and appends it to the clipboard:
// background.js chrome.commands.onCommand.addListener(function(command) { if (command === 'scrape-page') { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.executeScript(tabs[0].id, { code: 'document.body.innerText' }, function(result) { var pageContent = result[0]; // Append page content to clipboard navigator.clipboard.writeText(pageContent); }); }); } }); chrome.commands.onCommand.addListener(function(command) { if (command === 'scrape-page') { // Code to scrape page and append to clipboard } }); // manifest.json { "name": "Page Scraper", "version": "1.0", "manifest_version": 2, "background": { "scripts": ["background.js"] }, "commands": { "scrape-page": { "suggested_key": { "default": "Space", "mac": "Space" }, "description": "Scrape current page content" } }, "permissions": [ "activeTab", "clipboardWrite" ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.