1

The specific use case is mostly for youtube although I would prefer being able to take a screenshot for any html5 video. It's hard to take a perfect screenshot on youtube because of the panel on the bottom and blur and stuff. I got the idea for this from a greasyfork script which has a feature for doing the same thing except it downloads a file instead of saving to clipboard. Having a file saved each time is messy and I have to copy paste it anyways so copying directly would be better.

I will run the javascript code through tampermonkey or some other extension which can execute code on chrome's console through a shortcut. My plan was to somehow merge the frame extraction code from the script with the copy image to clipboard code but neither of those things are working.

Should've work to copy images but didn't: https://stackoverflow.com/a/59462028/13457082

Script Link: https://greasyfork.org/zh-CN/scripts/381682-html5%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E5%99%A8%E5%A2%9E%E5%BC%BA%E8%84%9A%E6%9C%AC

Script Code: https://p.ip.fi/nWOq
The code is 3346 lines long (altho relevant part is small) and the comments are in Chinese

Sarthak
  • 43
  • 7

1 Answers1

0

The screen capture function can probably be done with the Screen Capture API described here: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture

The tricky part is to copy an image to clipboard. What you can do is convert the image to a blob and then call navigator.clipboard.write function and attach the blob to it

Keystone Jack
  • 309
  • 1
  • 4
  • 13