can you code me a tampermonkey script that will capture the current frame of the playing…
- User
can you code me a tampermonkey script that will capture the current frame of the playing video and have either the option to save it, or copy to clipboard?
- Assistant
Sure, I can help you create a Tampermonkey script that captures the current frame of a playing video and provides options to save it or copy it to the clipboard. Here's a script that should work for most HTML5 videos:
javascript// ==UserScript== // @name Video Frame Capture // @namespace http://tampermonkey.net/ // @version 0.1 // @description Capture the current frame of a playing video and save or copy to clipboard. // @author Your Name // @match *://*/* // @grant GM_registerMenuCommand // @grant GM_setClipboard // ==/UserScript== (function() { 'use strict'; function captureVideoFrame(video) { const canvas = document.createElement('canvas'); canvas.width = video.videoWidth; canvas.height = video.videoHeight; const context = canvas.getContext('2d'); context.drawImage(video, 0, 0, canvas.width, canvas.height); return canvas.toDataURL('image/png'); } function saveImage(dataURL, filename) { const link = document.createElement('a'); link.href = dataURL; link.download = filename; link.click(); } function copyImageToClipboard(dataURL) { GM_setClipboard(dataURL, 'image/png'); } function captureAndSaveOrCopy() { const video = document.querySelector('video'); if (!video || !video.paused) { alert('No playing video found.'); return; } const dataURL = captureVideoFrame(video); const saveOption = confirm('Do you want to save the image? Click "OK" to save, or "Cancel" to copy to clipboard.'); if (saveOption) { const filename = prompt('Enter a filename (with .png extension):', 'video_frame.png'); if (filename) { saveImage(dataURL, filename); } } else { copyImageToClipboard(dataURL); } } GM_registerMenuCommand('Capture Video Frame', captureAndSaveOrCopy, 'c'); })(); - User
I don't think you finished, can you finish from saveButton.style.borderRad
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.