-
Star
(101)
You must be signed in to star a gist -
Fork
(11)
You must be signed in to fork a gist
-
-
Save rmtbb/e42d870a59a7f98091e734674831072b to your computer and use it in GitHub Desktop.
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard |
Nice suggestion @rmtbb, it works!
And I prefer this version, with a prompt. I can see what's inputed, and I don't need to enable insecure preferences. You should put it in the first comment.
Happy to hear it!
I have updated the original comment to include it (and shouted you out for requesting it).
Thanks for the idea, keep hacking!
Just found this bookmarklet. Awesome work on this, @rmtbb!
For those interested, you can find rmtbb's minified version of this bookmarklet here.
Recently, there have been a few updates to bookmarkl.ink that may be helpful for projects like this one e.g., TypeScript support, minification via esbuild, injected variables, bundling external deps, etc. You can also edit the bookmarklet source directly.
Here's a version that checks navigator.clipboard
compatibility before falling back to prompt()
. Alternatively, this behaviour can be forced using the PROMPT boolean variable. It contains the non-minified code as minification is done by bookmarkl.ink's bundler.
Great work @ashtonmeuser !!
Nice suggestion @rmtbb, it works!
And I prefer this version, with a prompt. I can see what's inputed, and I don't need to enable insecure preferences. You should put it in the first comment.