Jump to content

YOURLS URL shortening


Recommended Posts

Hi all,

 

this will be my first shared Alfred 2 WF 

..please be advised, that I am no scripting expert :)

 

What I did is to create a WF to make use of my yourls set up (http://yourls.org - custom php script to shorten urls)

The WF will grab the frontmost URL in Safari (you might want to change the browser in the script), curl it, and copy the URL to the clipboard as well as posting a notification.

 

Bildschirmfoto%202013-04-10%20um%2018.06

 

 

Important:

Be sure to make the necessary changes in the script.

What you need to enter is your URL where yourls is located and your API token.

I chose to make Safari the browser of choice, you might want to change that within the script, too.

 

You obviously will need a running installation of YOURLS ;)

 

Here's the download: http://d.pr/f/M7Xo

 

Have fun!

Edited by andi242
Link to comment

Do you have a github repo for this? There are some details of my PinAdd workflow that I think would be nice additions to this — configuring without the need to manually alter the script, and support for more browsers (each of them needs a different Applescript way of getting the frontmost tab url).

If not, would you mind if I took a crack at it?

Link to comment

I think I’m finished (added options to configure without the need for manually editing the file, and support for more browsers). Since I don’t use the service, there’s really not an easy way to test it. Are you interested? This doesn’t really add anything to the script that you’d need, so I can ask for anyone else on the forum, if you prefer.

Link to comment

Is there any way to grab the url from the clipboard instead of Safari?

 

Yes, it’s very simple with bash. There’s probably a way to do this using only applescript, but this also works.

On the script, change the line

property theURL : ""

to be

property theURL : (do shell script "pbpaste")

then simply delete these lines

tell application "Safari"
	
	set theURL to URL of current tab of window 1
	
end tell

And it should work like you want.

Edited by Vítor
Link to comment
  • 1 month later...

Thanks for this workflow! Works great!

 

Is it possible to use a custom short url ending? - Example:

  • I open Alfred
  • type yourls
  • enter my preferred short url, e.g. alfred

Result: short url is like abc.de/alfred

ooops, sorry, I did not check the forum for quite a while. did you come up with a solution, yet? :)

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...