hnakamur / FormatLink-Chrome

Format a link and title of the active tab of Chrome and MS Edge and copy it the clipboard
https://chrome.google.com/webstore/detail/format-link/pocemhmkmchpgamlnocemnbhlcjcbjgg?hl=ja
MIT License
10 stars 2 forks source link

Support text/html clipboardData #11

Closed dunkla closed 4 years ago

dunkla commented 4 years ago

I use some applications/websites which understand formatted copy-paste-data. By adding "text/html" to clipboard, we could use a real formatted link when using html-format:

diff --git a/clipboard-helper.js b/clipboard-helper.js
index 5f2027e..cb8ef8f 100644
--- a/clipboard-helper.js
+++ b/clipboard-helper.js
@@ -9,6 +9,7 @@ function FormatLink_copyTextToClipboard(text) {
     // Overwrite the clipboard content.
     event.preventDefault();
     event.clipboardData.setData("text/plain", text);
+    event.clipboardData.setData("text/html", text);
   }
   document.addEventListener("copy", oncopy, true);