ultragtx / FormatLink-Safari

Format the url and the title of the Safari active tab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Format Link for Safari

Download

  • FormatLink.safariextz
    • Safari 12+ does not allow unsafe extensions, you need to build the extension yourself
  • Or build the extension yourself: Safari Develop -> Show Extension Builder

Why do I need it?

To format the link of the active tab instantly to use in Markdown, Textile or other formats.

How to use

  1. Press the toolbar icon of "Format Link".
  2. When a popup opens, press Command-C to copy the formatted link to the clipboard.

Also you can change the format for one time only with selecting the format in the dropdown list.

Flexible settings

You can modify formats in [Safari]/[Preferences] -> [Extensions]. In format settings, you can use the mini template language.

  • {{variable}}
    • variable = title / url
    • No spaces are allowed.
  • {{variable.s("foo","bar")}}
    • Which means variable.replace(new RegExp("foo", 'g'), "bar")
    • You can use escape character \ in strings.
    • You must escape the first argument for string and regexp. For example, .s("\[","\[") means replacing [ with \[
    • You can chain multiple .s("foo","bar")
  • You can use the escape character \
  • Other characters are treated as literal strings.

Here are examples:

  • Markdown
    • [{{title.s("\\[","\\[").s("\\]","\\]")}}]({{url.s("\\)","%29")}})
  • Redmine Textile
    • "{{title.s("\"",""").s("\\[","[")}}":{{url}}
  • HTML
    • <a href="{{url.s("\"","&quot;")}}">{{title.s("<","&lt;")}}</a>
  • Text
    • {{title}}\n{{url}}

License

MIT License. Source codes are hosted at Github

Icon credits

I synthesized two icons (a pencil and a link) to produce Icon.png.

About

Format the url and the title of the Safari active tab

License:MIT License


Languages

Language:JavaScript 90.2%Language:HTML 9.8%