Last active
          November 9, 2022 22:00 
        
      - 
      
 - 
        
Save tayiorbeii/f825253120ffd74f9f1c597dcba6ed7d to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Name: Embed clipboard url in Notion | |
| // Description: Types /embed and pastes the clipboard url into Notion | |
| import "@johnlindquist/kit" | |
| await hide() | |
| let link = await paste() | |
| // parse the link from markdown string | |
| let regex = /\[(.+)\]\((.+)\)/ | |
| // extract a url from a string | |
| let urlRegex = /(https?:\/\/[^\s]+)/g | |
| if (link.match(regex)?.length >= 1) { | |
| link = link.match(regex)[1] | |
| } else if (link.match(urlRegex)?.length >= 1) { | |
| link = link.match(urlRegex)[0] | |
| } | |
| await keyboard.type("/emb") | |
| await keyboard.pressKey(Key.Enter) | |
| await wait(250) | |
| await keyboard.type(link) | |
| await keyboard.pressKey(Key.Enter) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment