K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmUrlBorg

Submitted by: rstlne



Notes:

Generate a short URL from a page or link using urlBorg. To invoke, use the urlBorg command in the document or link popup menus.

This macro is similar to the bookmarklet provided by urlBorg. The difference is the macro works even if you've set your bookmark options so that bookmarks open in a new layer. That setting breaks the bookmarklet.




Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

urlborg.kmm

# urlborg.kmm
#
# Macros for generating a short URL from a page or link using urlBorg.

_urlborg{
# Temporarily turn off popup blocking.
$__blockpref="dom.disable_open_during_load";
$__b=getpref(BOOL,$__blockpref);
setpref(BOOL,$__blockpref,false);

$__s="(function(){var g=window.open('','_blank','width=750px,height=500px');";
$__s=$__s."setTimeout(function(){g.focus()},100);var d=g.document;";
$__s=$__s."var i=d.createElement('input');i.name='url';";
$__s=$__s."i.value='".$_urlborg_url."';";
$__s=$__s."var f = d.createElement('form');";
$__s=$__s."f.action = 'http://urlborg.com/a/';f.method='POST';";
$__s=$__s."f.appendChild(i);d.body.appendChild(f);f.submit();})()";
injectJS($__s);

# Restore popup blocking if it was turned on previously.
setpref(BOOL,$__blockpref,$__b);
}

urlborg_page{
menugrayed=(hostname($URL)=="");
$_urlborg_url=$URL; &_urlborg;
}

urlborg_link{
$_urlborg_url=$LinkURL; &_urlborg;
}

_urlborg_buildmenu{
setmenu(Document,macro,"urlBorg of page",urlborg_page,-1);
setmenu(LinkPopup,macro,"urlBorg of link",urlborg_link,-1);
setmenu(FrameLinkPopup,macro,"urlBorg of link",urlborg_link,-1);
}

$OnInit=$OnInit."_urlborg_buildmenu;";
$macroModules=$macroModules."urlborg;";

# vim:set tw=0:
# -- The End --


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.