Advertisement
nrzmalik

Clipboard text paste JavaScript

Oct 6th, 2023
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.63 KB | Source Code | 0 0
  1. var player = GetPlayer();
  2. var editor = player.GetVar("editor");
  3. // Get the clipboard text
  4. navigator.clipboard.readText()
  5.   .then((clipboardText) => {
  6.     // Get the current content of the editor
  7.     let currentContent = editor;
  8.  
  9.     // Append the clipboard text after the previous content
  10.     let updatedContent = currentContent + clipboardText;
  11.  
  12.     // Update the editor variable with the combined content
  13.     player.SetVar("editor",updatedContent);
  14.  
  15.     // You can now use editorVariable with the clipboard text appended to it
  16.   })
  17.   .catch((error) => {
  18.     console.error('Failed to read clipboard text:', error);
  19.   });
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement