can you write a chrome extension that complies with chromes content security policy. it has a title "Sync Waves". a upper section titled audio with a place to put a youtube url and a place to load a local file of only audio files that are supported and a place to put a start time int titled seconds also a load button. a lower section that is the same as the upper section but is titled video. a section bellow that that has a play button, a pause button, and a resume button. the load buttons both should load the youtube video then play it for a eighth of a second then pause and set to the user specified start time. it should open in a new tab without any popup windows. i only want the completed updated files. center everything and make it responsive. make a radial gradient behind everything with white in the center and the outside color changes to all the main colors for 8 seconds then ends on black.
Assistant
Sure! Below are the complete files for the Chrome extension titled "Sync Waves" that comply with Chrome's Content Security Policy (CSP). This extension overrides the new tab page to provide the desired functionality.
1. manifest.json
This file defines the extension's metadata, permissions, and the new tab override.
json
{
"manifest_version": 3,
"name": "Sync Waves",
"version": "1.0",
"description": "Sync audio and video from YouTube or local files.",
"permissions": [],
"chrome_url_overrides": {
"newtab": "newtab.html"
},
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
}
Note: Make sure to include icon files in the icons directory as specified, or remove the icons section if you prefer not to include them.
2. newtab.html
This file structures the user interface with sections for audio and video inputs and control buttons.
This file handles the functionality of loading media, controlling playback, and syncing start times.
javascript
Important Notes:
YouTube Media Handling: Due to Chrome's Content Security Policy and limitations with directly extracting audio from YouTube, the above implementation uses the YouTube embed method for audio by muting the video element. For a more robust audio extraction, consider using YouTube's API or alternative methods, keeping in mind the compliance with YouTube's terms of service.
Local File Handling: The extension allows users to load local audio and video files using the file input elements. It creates object URLs for the selected files and assigns them to the respective media elements.
Media Controls: The play, pause, and resume buttons control both audio and video elements simultaneously.
Start Time Syncing: After loading media (from YouTube or local files), the extension plays the media for 1/8th of a second (125 milliseconds) before pausing and seeking to the user-specified start time.
Radial Gradient Animation: The background transitions through the main colors over 8 seconds and ends on black, as specified.
5. Directory Structure
Ensure your extension directory has the following structure: