Version at: 09/05/2013, 03:25

#Bookmarklets

## Drag-and-drop Alan's Bookmarklet to Your Bookmarks Toolbar

* Go to [Tools for Tatoeba.org Members](http://a4esl.com/temporary/tatoeba/things.html) and you can find the bookmarklet at the top of the page.

##About Bookmarklets

A bookmarklet is a relatively short piece of JavaScript code (of perhaps 100 to 2000 characters in length) that the browser runs on the current page. It begins with "javascript:" instead of "http://". Otherwise, you can treat it just like any standard bookmark. For instance, in Firefox, you can keep a bookmarklet together with your other bookmarks on the bookmark bar.

Whereas a [user script](user-scripts) is typically installed from a site such as [http://userscripts.org](userscripts.org), bookmarklets can be saved by whichever means you use to create a bookmark. Simply replace the "Location" or "URL" field by the bookmarklet string.

##Tatoeba bookmarklets

The following bookmarklet (author: AlanF_US), which will operate on any Tatoeba page (i.e., a page beginning with the string "http://tatoeba.org"), will let you link two sentences by copying their IDs or URLs into fields. It is based on a [bookmark by Zifre](http://tatoeba.org/eng/wall/show_message/4566#message_4566), but it has the following advantages:

- It does not require you to be on a page that shows one of the sentences.

- It will accept either a sentence number (e.g., "1000000") or a sentence URL (e.g., "http://tatoeba.org/eng/sentences/show/1000000"). Since right-clicking on a link to a sentence and choosing "Copy Link Location" (or its equivalent in your browser) will give you a full URL, the ability to copy in a URL saves you work because you don't need to trim the leading part of the URL before submitting it.

The text of the bookmarklet follows:


javascript:var%20u=0;var%20e="Enter%20number%20or%20URL%20of%20";var%20s="%20sentence";var%20a=window.prompt(e+"first"+s,"");if(a!=null){var%20t=/(http:\/\/tatoeba.org\/[a-z]{3}\/sentences\/show\/)?([1-9][0-9]*)/;var%20r=a.match(t);if(r!=null){var%20an=r[2];var%20b=window.prompt(e+"second"+s,"");if(b!=null){r=b.match(t);if(r!=null){var%20bn=r[2];u%20=1;c="http://tatoeba.org/eng/links/add"+"/"+an+"/"+bn;location.href=c;}}}}if(u==0){window.alert("Invalid%20input");}

##See also
See the [Wikipedia page on bookmarklets](http://en.wikipedia.org/wiki/Bookmarklet) or [this short introduction](http://betterexplained.com/articles/how-to-make-a-bookmarklet-for-your-web-application/) for more details on bookmarklets.

version at: 02/08/2013, 12:13

#Bookmarklets

A bookmarklet is a tool you can keep on your bookmarks bar that will perform an action when you click on it. You can use one of the bookmarklets on this page to link sentences that are not already indirectly linked. For more details about bookmarklets, see "About Bookmarklets" below.

## Drag-and-drop Alan's "Link 2 Sentences" Bookmarklet to Your Bookmarks Toolbar

* Go to [Tools for Tatoeba.org Members](http://bit.ly/tatoebatools) and you can find the bookmarklet at the top of the page.

##Tatoeba bookmarklets

The following bookmarklet (author: AlanF_US), which will operate on any Tatoeba page (i.e., a page beginning with the string "http://tatoeba.org"), will let you link two sentences by copying their IDs or URLs into fields. It is based on a [bookmark by Zifre](http://tatoeba.org/eng/wall/show_message/4566#message_4566), but it has the following advantages:

- It does not require you to be on a page that shows one of the sentences.

- It will accept either a sentence number (e.g., "1000000") or a sentence URL (e.g., "http://tatoeba.org/eng/sentences/show/1000000"). Since right-clicking on a link to a sentence and choosing "Copy Link Location" (or its equivalent in your browser) will give you a full URL, the ability to copy in a URL saves you work because you don't need to trim the leading part of the URL before submitting it.

The text of the bookmarklet follows:


javascript:var%20u=0;var%20e="Enter%20number%20or%20URL%20of%20";var%20s="%20sentence";var%20a=window.prompt(e+"first"+s,"");if(a!=null){var%20t=/(http:\/\/tatoeba.org\/[a-z]{3}\/sentences\/show\/)?([1-9][0-9]*)/;var%20r=a.match(t);if(r!=null){var%20an=r[2];var%20b=window.prompt(e+"second"+s,"");if(b!=null){r=b.match(t);if(r!=null){var%20bn=r[2];u%20=1;c="http://tatoeba.org/eng/links/add"+"/"+an+"/"+bn;location.href=c;}}}}if(u==0){window.alert("Invalid%20input");}

##About Bookmarklets

A bookmarklet is a short piece of JavaScript code that the browser runs on the current page. It begins with "javascript:" instead of "http://". Otherwise, you can treat it just like any standard bookmark. For instance, you can keep it on the bookmark bar.
Bookmarklets can be built from scratch by creating a bookmark from any web page, then changing the "Location" or "URL" field to the bookmarklet string and changing the name to whatever you want. See the [Wikipedia page on bookmarklets](http://en.wikipedia.org/wiki/Bookmarklet) or [this short introduction](http://betterexplained.com/articles/how-to-make-a-bookmarklet-for-your-web-application/) for more details.

Note

The lines in green are the lines that have been added in the new version. The lines in red are those that have been removed.