A bookmarklet to share the content in your selection + the URL with a custom ChatGPT.
The custom GPT will then fetch the content of the URL for additional context.
javascript:(function()%7Btry%7Bvar selection = window.getSelection ? window.getSelection().toString().trim() : %27%27;var currentUrl = window.location.href || %27URL unavailable%27;var message = selection || `Fetch content from ${currentUrl} for context. Please wait for further instructions.`;var baseMessage = `I copied this content:%5Cn%5Cn>>>%5Cn${message}%5Cn>>>%5Cn%5CnFrom this URL: ${currentUrl}%5CnFetch this URL for more context.%5Cn%5CnPlease wait for further instructions.`;var encodedMessage = encodeURIComponent(baseMessage);var targetUrl = `https://chat.openai.com/g/g-soMXGp85o-franz-enzenhofers-copy-and-fetch/?q=${encodedMessage}`;var newTab = window.open(targetUrl, %27_blank%27);if (!newTab) %7Bthrow new Error(%27Failed to open a new tab. Please check if pop-up blockers are enabled and try again.%27);%7D%7Dcatch (error)%7Bconsole.error(%27Bookmarklet Error:%27, error.message);alert(%27An error occurred while executing the bookmarklet. Please check the console for more details.%27);%7D%7D)();
For a quick and easy installation, you can simply drag the following link to your bookmarks bar:
If the above method doesn't work, follow the manual installation guide.
Enter a URL and selection text to simulate the bookmarklet:
// Immediately Invoked Function Expression (IIFE) for encapsulation.
(function() {
try {
// Get selected text or fallback to empty string
var selection = window.getSelection ? window.getSelection().toString().trim() : '';
// Get current URL or fallback to 'URL unavailable'
var currentUrl = window.location.href || 'URL unavailable';
// Create message from selection or URL
var message = selection || `Fetch content from ${currentUrl} for context.`;
// Format base message with content and URL
var baseMessage = `I copied this content:\n\n>>>\n${message}\n>>>\n\nFrom this URL: ${currentUrl}\nFetch this URL for more context.\n\nPlease wait for further instructions.`;
// Encode message for URL parameter
var encodedMessage = encodeURIComponent(baseMessage);
// Construct target URL with encoded message
var targetUrl = `https://chat.openai.com/g/g-soMXGp85o-franz-enzenhofers-copy-and-fetch/?q=${encodedMessage}`;
// Open new tab with target URL
var newTab = window.open(targetUrl, '_blank');
// Throw error if new tab couldn't be opened
if (!newTab) throw new Error('Failed to open a new tab. Check pop-up blockers.');
} catch (error) {
// Log error and alert user
console.error('Bookmarklet Error:', error.message);
alert('An error occurred. Check the console for details.');
}
})();
Navigate to any web page → Select any text → Click the "Copy and Fetch" bookmark → A new tab opens with ChatGPT → Wait 5 seconds and the selected content and URL will be pre-filled into ChatGPT!
Feedback and comments. Please share them on this Hacker News post: