Return to Snippet

Revision: 1400
at October 3, 2006 05:48 by mlange


Initial Code
/*
Bookmarklets/Favelets are free tools to help with repetitive or otherwise impossible tasks in your web browser. 

Add any of these Favelets to your Favorites, or drag them to your Favorites Toolbar. Then load a page, click the favelet in your toolbar and go.
*/


// -------------------------------
//    extractring friends info (XFN)

/* 
Source: <a href="http://meyerweb.com/eric/tools/xfn/">xfn tools</a> @ meyerweb
/*

javascript:LiP=document.getElementsByTagName('a');XLiP=new%20Array();XFNregex=/(acquaintance|
friend|met|co-worker|colleague|co-resident|neighbor|child|parent|sibling|spouse|muse|crush|date|
sweetheart)/;for%20(i=0;i%3CLiP.length;i++)%20{%20if%20(XFNregex.test(LiP[i].rel))%20{XLiP.push(LiP[i]);LiP
[i].style.background='%23FF0';}}if%20(XLiP.length%20!=%200)%20{dS='%3Chtml%3E%3Chead%3E%3Ctitle%
3EXFN%20Links%3C\/title%3E%3Cstyle%20type=%22text\/css%22%3Etd{border-bottom:1px%20solid%20%
23DDD;}.l{padding-right:1em;}%3C\/style%3E%3C\/head%3E%3Cbody%3E%3Cp%3E'+XLiP.length+'%
20friendly%20links%20out%20of%20'+LiP.length+'%20total%20links%3C\/p%3E%3Ctable%20cellspacing=%
220%22%3E';for(i%20in%20XLiP)%20{dS+='%3Ctr%3E%3Ctd%20class=%22l%22%3E%3Ca%20href=%22'+XLiP
[i].href+'%22%20title=%22'+XLiP[i].title+'%22%3E'+XLiP[i].innerHTML+'%3C\/a%3E%3C\/td%3E%3Ctd%
3E'+XLiP[i].rel+'%3C\/td%3E%3C\/tr%3E';}dS+='%3C\/table%3E%3C\/body%3E%3C\/html%
3E';dump=window.open
('','XFNlinks','top=10,left=10,status=yes,resizable=yes,menubar=yes,width=800,height=600');dump.focus
();dump.document.write(dS);}%20else%20{alert('No%20XFN%20links%20detected.');}


// -------------------------------
//    Bookmarklets @ howtocreate

/*
Source: <a href="http://www.howtocreate.co.uk/bookmarklets.html">bookmarklets</a> @ howtocreate
*/

// -------------------------------
//   Dom path

/*
Uses the status bar to display the DOM path to the element under the mouse (Opera 7+, IE 5+, Mozilla/Netscape 6+, Safari) - [Instructions: open the page, click the bookmarklet, move the mouse over the page to see the DOM path in the status bar - Note: some browsers have the status bar hidden by default]
*/

javascript:void(document.onmousemove=function%20(e)%20{if(!e){e=window.event;}if(e){e=e.target?
e.target:e.srcElement;}if(!e){return;}for(var%20oStr='';e&&e.nodeName!='%23document';e=e.parentNode){if
(e.nodeName!='%23text'){for(var%20oCount=0,oOb=e.previousSibling;oOb;oOb=oOb.previousSibling){if
(oOb.nodeName==e.nodeName){oCount++;}}oStr=e.nodeName+(oCount?('%23'+(oCount+1)):'')+(oStr?
('/'+oStr):'');}}window.status=oStr;});



// -------------------------------
//    Scripts

javascript:var%20MTl=document.getElementsByTagName('script');for(var%20MTi=0,MTr,MTa=[];MTl
[MTi];MTi++){if(MTr=MTl[MTi].getAttribute('src')){MTa[MTa.length]=MTl[MTi];}}if(!MTa.length){alert('This%
20page%20does%20not%20use%20any%20external%20scripts');}else%20if(MTa.length==1){void
(window.open(MTa[0].getAttribute('src')));}else{var%20MTw=window.open('');MTw.document.open
();MTw.document.write('%3Chtml%3E%3Chead%3E%3Ctitle%3EExternal%20scripts%20for%20'+document.title
+'%3C//title%3E%3C//head%3E%3Cbody%3E%3Ch1%3EExternal%20scripts%20for%20'+document.title+'%
3C//h1%3E%3Cp%3E');for(MTi=0;MTa[MTi];MTi++){MTw.document.write('%3Ca%20href=/''+MTa
[MTi].getAttribute('src')+'/'%3E'+(MTa[MTi].id?MTa[MTi].id:MTa[MTi].getAttribute('src').replace(/\/
$/,'').replace(/^.*\//,''))+'%3C\/a%3E%3Cbr%3E');}MTw.document.write('%3C\/p%3E%3C\/body%3E%3C\/
html%3E');MTw.document.close();}



// -------------------------------
//    Stylesheets

/*
Opens a window with links to every stylesheet used on the page - if there is only one stylesheet, it will be opened immediately (Opera 7+, IE 5+, Mozilla/Netscape 6+, Safari)
*/

javascript:var%20MTl=document.getElementsByTagName('link');for(var%20MTi=0,MTr,MTa=[];MTl[MTi];MTi
++){if(MTr=MTl[MTi].getAttribute('rel')){if(MTr.toLowerCase().indexOf('stylesheet')+1){MTa[MTa.length]
=MTl[MTi];}}}if(!MTa.length){alert('This%20page%20does%20not%20use%20any%20linked%20stylesheets');}
else%20if(MTa.length==1){void(window.open(MTa[0].href));}else{var%20MTw=window.open
('');MTw.document.open();MTw.document.write('%3Chtml%3E%3Chead%3E%3Ctitle%3EStylesheets%20for%
20'+document.title+'%3C//title%3E%3C//head%3E%3Cbody%3E%3Ch1%3EStylesheets%20for%
20'+document.title+'%3C//h1%3E%3Cp%3E');for(MTi=0;MTa[MTi];MTi++){MTw.document.write('%3Ca%
20href=/''+MTa[MTi].href+'/'%3E'+(MTa[MTi].title?MTa[MTi].title:MTa[MTi].getAttribute('href').replace(/
^data:.*$/i,'data:URI').replace(/\/$/,'').replace(/^.*\//,''))+'%3C\/a%3E%3Cbr%3E');}MTw.document.write('%
3C\/p%3E%3C\/body%3E%3C\/html%3E');MTw.document.close();}



// -------------------------------
//    CSS DOM

/*
Searches the page and all frames for inline, linked, and imported stylesheets, and displays their contents in a list, with links to all relevant files (Opera 9+, Mozilla)
*/

javascript:(function%20()%20{function%20describeSheet(oDoc,oSheet)%20{var%20oLi%20=%
20oDoc.createElement('li');try%20{%20void(oSheet.href);%20}%20catch(e)%20{oLi.appendChild
(oDoc.createTextNode('Stylesheet%20with%20access%20forbidden'));return%20oLi;}if(%20oSheet.href%20)%
20{oLi.appendChild(oDoc.createTextNode('Stylesheet%20'));var%20oHref%20=%20oDoc.createElement
('a');oHref.setAttribute('href',oSheet.href);var%20oShortHref%20=%20oSheet.title%20?%20oSheet.title%20:%
20(%20(%20oSheet.href.indexOf('data:')%20==%200%20)%20?%20oSheet.href%20:%20oSheet.href.replace(/
^.*\//,'').replace(/\.[^\.]*$/,'')%20);oShortHref%20=%20oShortHref%20?%20oShortHref%20:%
20'untitled';oShortHref%20=%20(%20oShortHref.length%20%3C%2040%20)%20?%20oShortHref%20:%20(%
20oShortHref.substring(0,18)%20+%20'...'%20+%20oShortHref.substring(oShortHref.length-19)%
20);oHref.appendChild(oDoc.createTextNode(oShortHref));oLi.appendChild(oHref);}%20else%20
{oLi.appendChild(oDoc.createTextNode('Inline%20stylesheet'));}oLi.appendChild(oDoc.createTextNode('%20
('+(%20(%20oSheet.ownerNode%20&&%20oSheet.ownerNode.hasAttribute('rel')%20&&%
20oSheet.ownerNode.getAttribute('rel').indexOf('alternate')%20+%201%20)%20?%20'alternate%20-%20'%
20:%20''%20)+(oSheet.disabled?'disabled':'enabled')+')%20'));oLi.appendChild(getMediaList
(oDoc,oSheet));try%20{%20oLi.appendChild(getRulesInBlock(oDoc,oSheet,true));%20}%20catch(f)%20
{oLi.appendChild(oDoc.createTextNode('%20(access%20forbidden)'));}return%20oLi;}function%
20getStylesInRule(oDoc,oRule)%20{var%20oDL%20=%20oDoc.createElement('dl');for(%20var%20i%20=%
200,%20j,%20k;%20i%20%3C%20oRule.style.length;%20i++%20)%20{j%20=%20oRule.style.item(i);var%20oDt
%20=%20oDoc.createElement('dt');var%20oDd%20=%20oDoc.createElement('dd');oDL.appendChild
(oDt);oDL.appendChild(oDd);k%20=%20oRule.style.getPropertyPriority(j);oDt.appendChild
(oDoc.createTextNode(j+':'));oDd.appendChild(oDoc.createTextNode(oRule.style.getPropertyValue(j)+(k?('%
20!'+k):'')+';'));}return%20oDL;}function%20getMediaList(oDoc,oRule)%20{if(%20!oRule.media.length%20)%
20{%20return%20oDoc.createTextNode('');%20}var%20oUL%20=%20oDoc.createElement('ul');oUL.className
%20=%20'medlist';for(%20var%20i%20=%200;%20i%20%3C%20oRule.media.length;%20i++%20)%20{var%
20oLi%20=%20oDoc.createElement('li');oUL.appendChild(oLi);oLi.appendChild(oDoc.createTextNode
(oRule.media.item(i)));}return%20oUL;}function%20getRulesInBlock(oDoc,oBlock,isRoot)%20{var%20oUL%20=
%20oDoc.createElement('ul');if(%20isRoot%20)%20{%20oUL.className%20=%20'fileroot';%20}for(%20var%
20n%20=%200,%20m;%20n%20%3C%20oBlock.cssRules.length;%20n++%20)%20{m%20=%
20oBlock.cssRules.item(n);var%20oLi%20=%20oDoc.createElement('li');oUL.appendChild(oLi);if(%20m.type%
20==%201%20||%20m.type%20==%205%20||%20m.type%20==%206%20)%20{oLi.appendChild
(oDoc.createTextNode(m.selectorText+'%20{%20'));oLi.appendChild(getStylesInRule
(oDoc,m));oLi.appendChild(oDoc.createTextNode('}'));}%20else%20if(%20m.type%20==%202%20)%20
{oLi.appendChild(oDoc.createTextNode('@charset%20\''+m.encoding+'\';'));}%20else%20if(%20m.type%
20==%204%20)%20{oLi.appendChild(oDoc.createTextNode('@media%20'));oLi.appendChild(getMediaList
(oDoc,m));oLi.appendChild(oDoc.createTextNode('%20{%20'));oLi.appendChild(getRulesInBlock
(oDoc,m));oLi.appendChild(oDoc.createTextNode('}'));}%20else%20if(%20m.type%20==%203%20)%20
{oLi.appendChild(oDoc.createTextNode('@import%20url('));var%20oHref%20=%20oDoc.createElement
('a');oHref.setAttribute('href',m.styleSheet.href);oHref.appendChild(document.createTextNode
(m.href));oLi.appendChild(oHref);oLi.appendChild(oDoc.createTextNode(');'));oLi.appendChild
(getRulesInBlock(oDoc,m.styleSheet,true));}%20else%20if(%20!m.type%20)%20{oLi.appendChild
(oDoc.createTextNode('@unknown%20rule;'));}}return%20oUL;}function%20listSheets(oDoc,oDocument)%20
{var%20oUL%20=%20oDoc.createElement('ol');oUL.className%20=%20'sheetlist';for(%20var%20i%20=%
200,%20j;%20i%20%3C%20oDocument.styleSheets.length;%20i++%20)%20{oUL.appendChild(describeSheet
(oDoc,oDocument.styleSheets.item(i)));}return%20oUL;}function%20getAllFrames(oWin,oDest,oPar)%20{var%
20oA,%20oH%20=%20oDest.createElement('h2'),%20li,%20ul%20=%20oDest.createElement
('ol');oH.appendChild(oDest.createTextNode('Frames'));oPar.appendChild(oH);oPar.appendChild(ul);for(%
20var%20i%20=%200,%20j;%20i%20%3C%20oWin.frames.length;%20i++%20)%20{li%20=%
20oDest.createElement('li');oH%20=%20oDest.createElement('h3');li.appendChild(oH);ul.appendChild(li);try%
20{j%20=%20oWin.frames[i];if(%20j.location%20)%20{oA%20=%20oDest.createElement('a');oA.setAttribute
('href',j.location.href);oA.appendChild(oDest.createTextNode(j.document.title?
j.document.title:j.location.href));oH.appendChild(oA);}%20else%20{oH.appendChild(oDest.createTextNode
('Page%20with%20no%20location%20object'));}if(%20j.document%20)%20{li.appendChild(listSheets
(oDest,j.document));if(%20j.frames.length%20)%20{getAllFrames(j,oDest,li);}}}%20catch(e)%20
{oH.appendChild(oDest.createTextNode('Frame%20from%20denied%20domain'));}}}var%20foo%20=%
20window.open('','_blank');foo.document.write('%3Chtml%3E%3Ctitle%3E%3C\/title%3E%3Cstyle%20type=
\'text\/css\'%3E\n'+'html,%20body%20{%20background:%20%23ddd;%20color:%20%23000;%20}\n'+'a%20
{%20color:%20%2300f;%20}\n'+'a:visited%20{%20color:%20%23909;%20}\n'+'ol,%20ul%20{%20background:%
20%23bbb;%20list-style-position:%20inside;%20padding:%201px;%20margin:%200.5em%202px;%20}
\n'+'ul,%20ol.sheetlist%20{%20background:%20%2388a;%20}\n'+'ul%20{%20background:%20%23aae;%
20display:%20block;%20list-style-type:%20none;%20}\n'+'ul.fileroot%20{%20background:%20%23797;%20}
\n'+'ul.medlist,%20ul.medlist%20li%20{%20background:%20transparent;%20display:%20inline;%20margin:%
200;%20padding:%200;%20}\n'+'ul.medlist%20li::before%20{%20content:%20\',%20\';%20}\n'+'ul.medlist%
20li:first-child::before%20{%20content:%20\'\';%20}\n'+'li%20{%20background:%20%23ddd;%20padding:%
201px;%20margin:%202px%202px%202px%201em;%20}\n'+'dl%20{%20padding:%200;%20margin:%200;%
20}\n'+(%20(%20navigator.product%20!=%20'Gecko'%20)%20?%20'dt,%20dd%20{%20display:%20inline;%
20white-space:%20pre;%20margin:%200;%20padding:%200%200%200%201em;%20}\n'%20:%20''%20)+'dd%
20{%20padding-left:%200.3em;%20}\n'+'dd::after%20{%20display:%20block;%20height:%201px;%
20content:%20\'\';%20}\n'+'\n%3C\/style%3E%3Cbody%3E%3C\/body%3E');foo.document.close();var%20oH
%20=%20foo.document.createElement('h1');oA%20=%20foo.document.createElement('a');oA.setAttribute
('href',location.href);oA.appendChild(foo.document.createTextNode(foo.document.title=('Stylesheets%
20for:%20'+(document.title?document.title:location.href))));oH.appendChild
(oA);foo.document.body.appendChild(oH);foo.document.body.appendChild(listSheets
(foo.document,document));if(%20window.frames.length%20)%20{%20getAllFrames
(window,foo.document,foo.document.body);%20}})();



// -------------------------------
//    Highlight

/*
Highlight: Attempts to syntax highlight JavaScript code for JavaScript files that you open (Opera 7.5+, Mozilla/Netscape 6+) - [Instructions: this one is a bit complicated. Firstly, download this zip file => <a href="http://www.howtocreate.co.uk/tutorials/jsexamples/syntax/bookmarkletSyntax.zip">bookmarkletSyntax.zip</a> <= and open it. Copy the file it contains to somewhere on your computer. Then use this form to select it: 

 Then use the link the same way as you would use any of the other bookmarklet links. - When you click it, it will open a window, but it may take a few seconds to highlight the code, please wait and allow it to do so]
*/

javascript:var%20theLocation='';if(!theLocation){alert('Bookmarklet%20not%20installed%20correctly./n/
nPlease%20follow%20the%20instructions%20given%20on%20the%20page.');}else{var%
20newScript=document.createElement('script');newScript.setAttribute('src',theLocation);void
(document.body.appendChild(newScript));var%20oWindMeUp%20=%20window.open
('','synWin','resizable=1,status=0,location=0,toolbar=0,scrollbars=1,top=0,left=0,height='+
(screen.height-59)+',width='+(screen.width-12));}

Initial URL


Initial Description


Initial Title
Useful bookmarklets

Initial Tags


Initial Language
JavaScript