The ChatGPT Code Preview Extension is a browser extension designed to enhance the coding experience on ChatGPT. It allows users to preview and interact with code snippets directly within the ChatGPT interface.
- Live Code Preview: Instantly see the output of HTML, CSS, and JavaScript code.
- Syntax Highlighting: View code with proper syntax highlighting for better readability.
- Copy Code: Easily copy the entire code snippet to your clipboard.
- Download Code: Download the code snippet as a file with the appropriate extension.
- Resizable Preview: Adjust the size of the preview panel to your liking.
- Download the extension files (manifest.json, content.js, and styles.css).
- Open your Chrome browser and navigate to
chrome://extensions/
. - Enable "Developer mode" in the top right corner.
- Click "Load unpacked" and select the folder containing the extension files.
- Visit ChatGPT (https://chat.openai.com/).
- When you see a code snippet, a "Preview" button will appear next to it.
- Click the "Preview" button to open the preview panel.
- Use the "Preview" and "Code" tabs to switch between the output and the source code.
- Use the "Copy Code" and "Download Code" buttons as needed.
To fully utilize the ChatGPT Code Preview Extension, you may need to use the CSP Unblock extension to bypass Content Security Policy restrictions. Here's how to set it up:
-
Install the CSP Unblock extension from the Chrome Web Store: CSP Unblock
-
Once installed, click on the extension icon in your browser toolbar to activate it for chat.openai.com.
-
The CSP Unblock extension will remove the following CSP-related response headers:
- "content-security-policy"
- "content-security-policy-report-only"
- "x-webkit-csp"
- "x-content-security-policy"
-
With CSP restrictions removed, the ChatGPT Code Preview Extension should now work without any limitations, allowing you to run scripts and load resources that would otherwise be blocked.
Remember to disable the CSP Unblock extension when you're not using ChatGPT or testing your extension. Removing CSP can significantly reduce a website's protection against certain types of attacks, so it should only be used when necessary and on trusted sites.
Feel free to contribute to this project by submitting pull requests or reporting issues on the project's GitHub repository.
This project is licensed under the MIT License.