Bookmarklets

Bookmarklets are smart bookmarks. They usually allow one to perform complex task via a single click (bookmark-toolbar).

Dokuwiki

Inspired by Dokuwiki-Weblog.

This bookmarklet directly POSTS to DokuWiki - it opens up a popup-window to create/preview a DokuWiki page about the currently browsed page, using the current selection as wiki-page text.

javascript:Q=document.selection?document.selection.createRange().text:document.getSelection();L=location.href;D=document.title;d=new Date();I=d.getFullYear()+':'+(d.getUTCMonth()+1)+'_'+d.getUTCDay()+'_'+d.getUTCHours()+''+d.getUTCMinutes()+''+d.getUTCSeconds(); myWindow=window.open('','dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=640,height=420,left=200,top=160,status=yes');f=myWindow.document.createElement('form');f.method='post';f.action='https://your.host/?id=wiki:weblog:'+I;i0=document.createElement('input');i0.type='hidden';i0.name='wikitext';i0.value='===== '+D+' =====\n  * '+L+'\n'+Q+'\n{{tag>Bookmark}}';i1=document.createElement('input');i1.type='hidden';i1.name='do';i1.value='preview';f.appendChild(i0);f.appendChild(i1);b=myWindow.document.getElementsByTagName('body')[0]; b.appendChild(f); f.submit();

This script may be too long for some browsers, see dokubookmark for an alternative.

Modify the action URL (https://your.host/), ID (wiki:weblog:<DATE>) and the wiki-page template wikitext=.. to your preference.

Note: the date syntax is not the same as the Dokuwiki-Weblog mentioned above. javascript's UTCMonth and UTCDay are values 1-12 and 1-31 rather than 01-12 or 01-31.

Misc Bookmarklets

Javascript bookmarklet to HTTP-POST.

javascript: (
  function() {
    document.open();                                        //  Empties the current browser page
    uri      = 'http://translate.google.com/translate_t';   //  Destination URI for the POST request
    f        = document.createElement('form');              //  Form creation
    f.method = 'post';                                      //    of POST type
    f.action = uri;                                         //    using the URI given above.
    i0       = document.createElement('input');             //  Field creation
    i0.type  = 'text';                                      //    of text type
    i0.name  = 'text';                                      //    called "text"
    i0.value = '%s';                                        //    which takes as input the words
                                                            //      given in the navigation bar
    i1       = document.createElement('input');             //  Second field creation
    i1.type  = 'hidden';                                    //    of hidden type
    i1.name  = 'langpair';                                  //    called "langpair"
    i1.value = 'fr|en';                                     //    that takes "fr|en", as argument,
                                                            //      understood by Google as
                                                            //      "translate from french to english"
    f.appendChild(i0);                                      //  Ties the first field to the form
    f.appendChild(i1);                                      //  Ties the second field to the form
    b        = document.createElement('body');              //  <body> element creation
    b.appendChild(f);                                       //  Ties the form to the <body>
    h        = document.getElementsByTagName('html')[0];    //  Get anchor point for <body>
    h.appendChild(b);                                       //  Ties the <body> to the current page
    f.submit();                                             //  Submits the form
  }
)()

source: http://ptaff.ca/smart/

 
wiki/bookmarklet.txt · Last modified: 01.01.2009 04:47 by rgareus