Posted By

mlange on 10/03/06


Tagged

bookmarklets favelets


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

shachi
mikegreen
wirenaught


Useful bookmarklets


 / Published in: JavaScript
 

  1. /*
  2. Bookmarklets/Favelets are free tools to help with repetitive or otherwise impossible tasks in your web browser.
  3.  
  4. 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.
  5. */
  6.  
  7.  
  8. // -------------------------------
  9. // extractring friends info (XFN)
  10.  
  11. /*
  12. Source: <a href="http://meyerweb.com/eric/tools/xfn/">xfn tools</a> @ meyerweb
  13. /*
  14.  
  15. javascript:LiP=document.getElementsByTagName('a');XLiP=new%20Array();XFNregex=/(acquaintance|
  16. friend|met|co-worker|colleague|co-resident|neighbor|child|parent|sibling|spouse|muse|crush|date|
  17. sweetheart)/;for%20(i=0;i%3CLiP.length;i++)%20{%20if%20(XFNregex.test(LiP[i].rel))%20{XLiP.push(LiP[i]);LiP
  18. [i].style.background='%23FF0';}}if%20(XLiP.length%20!=%200)%20{dS='%3Chtml%3E%3Chead%3E%3Ctitle%
  19. 3EXFN%20Links%3C\/title%3E%3Cstyle%20type=%22text\/css%22%3Etd{border-bottom:1px%20solid%20%
  20. 23DDD;}.l{padding-right:1em;}%3C\/style%3E%3C\/head%3E%3Cbody%3E%3Cp%3E'+XLiP.length+'%
  21. 20friendly%20links%20out%20of%20'+LiP.length+'%20total%20links%3C\/p%3E%3Ctable%20cellspacing=%
  22. 220%22%3E';for(i%20in%20XLiP)%20{dS+='%3Ctr%3E%3Ctd%20class=%22l%22%3E%3Ca%20href=%22'+XLiP
  23. [i].href+'%22%20title=%22'+XLiP[i].title+'%22%3E'+XLiP[i].innerHTML+'%3C\/a%3E%3C\/td%3E%3Ctd%
  24. 3E'+XLiP[i].rel+'%3C\/td%3E%3C\/tr%3E';}dS+='%3C\/table%3E%3C\/body%3E%3C\/html%
  25. 3E';dump=window.open
  26. ('','XFNlinks','top=10,left=10,status=yes,resizable=yes,menubar=yes,width=800,height=600');dump.focus
  27. ();dump.document.write(dS);}%20else%20{alert('No%20XFN%20links%20detected.');}
  28.  
  29.  
  30. // -------------------------------
  31. // Bookmarklets @ howtocreate
  32.  
  33. /*
  34. Source: <a href="http://www.howtocreate.co.uk/bookmarklets.html">bookmarklets</a> @ howtocreate
  35. */
  36.  
  37. // -------------------------------
  38. // Dom path
  39.  
  40. /*
  41. 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]
  42. */
  43.  
  44. javascript:void(document.onmousemove=function%20(e)%20{if(!e){e=window.event;}if(e){e=e.target?
  45. e.target:e.srcElement;}if(!e){return;}for(var%20oStr='';e&&e.nodeName!='%23document';e=e.parentNode){if
  46. (e.nodeName!='%23text'){for(var%20oCount=0,oOb=e.previousSibling;oOb;oOb=oOb.previousSibling){if
  47. (oOb.nodeName==e.nodeName){oCount++;}}oStr=e.nodeName+(oCount?('%23'+(oCount+1)):'')+(oStr?
  48. ('/'+oStr):'');}}window.status=oStr;});
  49.  
  50.  
  51.  
  52. // -------------------------------
  53. // Scripts
  54.  
  55. javascript:var%20MTl=document.getElementsByTagName('script');for(var%20MTi=0,MTr,MTa=[];MTl
  56. [MTi];MTi++){if(MTr=MTl[MTi].getAttribute('src')){MTa[MTa.length]=MTl[MTi];}}if(!MTa.length){alert('This%
  57. 20page%20does%20not%20use%20any%20external%20scripts');}else%20if(MTa.length==1){void
  58. (window.open(MTa[0].getAttribute('src')));}else{var%20MTw=window.open('');MTw.document.open
  59. ();MTw.document.write('%3Chtml%3E%3Chead%3E%3Ctitle%3EExternal%20scripts%20for%20'+document.title
  60. +'%3C//title%3E%3C//head%3E%3Cbody%3E%3Ch1%3EExternal%20scripts%20for%20'+document.title+'%
  61. 3C//h1%3E%3Cp%3E');for(MTi=0;MTa[MTi];MTi++){MTw.document.write('%3Ca%20href=/''+MTa
  62. [MTi].getAttribute('src')+'/'%3E'+(MTa[MTi].id?MTa[MTi].id:MTa[MTi].getAttribute('src').replace(/\/
  63. $/,'').replace(/^.*\//,''))+'%3C\/a%3E%3Cbr%3E');}MTw.document.write('%3C\/p%3E%3C\/body%3E%3C\/
  64. html%3E');MTw.document.close();}
  65.  
  66.  
  67.  
  68. // -------------------------------
  69. // Stylesheets
  70.  
  71. /*
  72. 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)
  73. */
  74.  
  75. javascript:var%20MTl=document.getElementsByTagName('link');for(var%20MTi=0,MTr,MTa=[];MTl[MTi];MTi
  76. ++){if(MTr=MTl[MTi].getAttribute('rel')){if(MTr.toLowerCase().indexOf('stylesheet')+1){MTa[MTa.length]
  77. =MTl[MTi];}}}if(!MTa.length){alert('This%20page%20does%20not%20use%20any%20linked%20stylesheets');}
  78. else%20if(MTa.length==1){void(window.open(MTa[0].href));}else{var%20MTw=window.open
  79. ('');MTw.document.open();MTw.document.write('%3Chtml%3E%3Chead%3E%3Ctitle%3EStylesheets%20for%
  80. 20'+document.title+'%3C//title%3E%3C//head%3E%3Cbody%3E%3Ch1%3EStylesheets%20for%
  81. 20'+document.title+'%3C//h1%3E%3Cp%3E');for(MTi=0;MTa[MTi];MTi++){MTw.document.write('%3Ca%
  82. 20href=/''+MTa[MTi].href+'/'%3E'+(MTa[MTi].title?MTa[MTi].title:MTa[MTi].getAttribute('href').replace(/
  83. ^data:.*$/i,'data:URI').replace(/\/$/,'').replace(/^.*\//,''))+'%3C\/a%3E%3Cbr%3E');}MTw.document.write('%
  84. 3C\/p%3E%3C\/body%3E%3C\/html%3E');MTw.document.close();}
  85.  
  86.  
  87.  
  88. // -------------------------------
  89. // CSS DOM
  90.  
  91. /*
  92. 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)
  93. */
  94.  
  95. javascript:(function%20()%20{function%20describeSheet(oDoc,oSheet)%20{var%20oLi%20=%
  96. 20oDoc.createElement('li');try%20{%20void(oSheet.href);%20}%20catch(e)%20{oLi.appendChild
  97. (oDoc.createTextNode('Stylesheet%20with%20access%20forbidden'));return%20oLi;}if(%20oSheet.href%20)%
  98. 20{oLi.appendChild(oDoc.createTextNode('Stylesheet%20'));var%20oHref%20=%20oDoc.createElement
  99. ('a');oHref.setAttribute('href',oSheet.href);var%20oShortHref%20=%20oSheet.title%20?%20oSheet.title%20:%
  100. 20(%20(%20oSheet.href.indexOf('data:')%20==%200%20)%20?%20oSheet.href%20:%20oSheet.href.replace(/
  101. ^.*\//,'').replace(/\.[^\.]*$/,'')%20);oShortHref%20=%20oShortHref%20?%20oShortHref%20:%
  102. 20'untitled';oShortHref%20=%20(%20oShortHref.length%20%3C%2040%20)%20?%20oShortHref%20:%20(%
  103. 20oShortHref.substring(0,18)%20+%20'...'%20+%20oShortHref.substring(oShortHref.length-19)%
  104. 20);oHref.appendChild(oDoc.createTextNode(oShortHref));oLi.appendChild(oHref);}%20else%20
  105. {oLi.appendChild(oDoc.createTextNode('Inline%20stylesheet'));}oLi.appendChild(oDoc.createTextNode('%20
  106. ('+(%20(%20oSheet.ownerNode%20&&%20oSheet.ownerNode.hasAttribute('rel')%20&&%
  107. 20oSheet.ownerNode.getAttribute('rel').indexOf('alternate')%20+%201%20)%20?%20'alternate%20-%20'%
  108. 20:%20''%20)+(oSheet.disabled?'disabled':'enabled')+')%20'));oLi.appendChild(getMediaList
  109. (oDoc,oSheet));try%20{%20oLi.appendChild(getRulesInBlock(oDoc,oSheet,true));%20}%20catch(f)%20
  110. {oLi.appendChild(oDoc.createTextNode('%20(access%20forbidden)'));}return%20oLi;}function%
  111. 20getStylesInRule(oDoc,oRule)%20{var%20oDL%20=%20oDoc.createElement('dl');for(%20var%20i%20=%
  112. 200,%20j,%20k;%20i%20%3C%20oRule.style.length;%20i++%20)%20{j%20=%20oRule.style.item(i);var%20oDt
  113. %20=%20oDoc.createElement('dt');var%20oDd%20=%20oDoc.createElement('dd');oDL.appendChild
  114. (oDt);oDL.appendChild(oDd);k%20=%20oRule.style.getPropertyPriority(j);oDt.appendChild
  115. (oDoc.createTextNode(j+':'));oDd.appendChild(oDoc.createTextNode(oRule.style.getPropertyValue(j)+(k?('%
  116. 20!'+k):'')+';'));}return%20oDL;}function%20getMediaList(oDoc,oRule)%20{if(%20!oRule.media.length%20)%
  117. 20{%20return%20oDoc.createTextNode('');%20}var%20oUL%20=%20oDoc.createElement('ul');oUL.className
  118. %20=%20'medlist';for(%20var%20i%20=%200;%20i%20%3C%20oRule.media.length;%20i++%20)%20{var%
  119. 20oLi%20=%20oDoc.createElement('li');oUL.appendChild(oLi);oLi.appendChild(oDoc.createTextNode
  120. (oRule.media.item(i)));}return%20oUL;}function%20getRulesInBlock(oDoc,oBlock,isRoot)%20{var%20oUL%20=
  121. %20oDoc.createElement('ul');if(%20isRoot%20)%20{%20oUL.className%20=%20'fileroot';%20}for(%20var%
  122. 20n%20=%200,%20m;%20n%20%3C%20oBlock.cssRules.length;%20n++%20)%20{m%20=%
  123. 20oBlock.cssRules.item(n);var%20oLi%20=%20oDoc.createElement('li');oUL.appendChild(oLi);if(%20m.type%
  124. 20==%201%20||%20m.type%20==%205%20||%20m.type%20==%206%20)%20{oLi.appendChild
  125. (oDoc.createTextNode(m.selectorText+'%20{%20'));oLi.appendChild(getStylesInRule
  126. (oDoc,m));oLi.appendChild(oDoc.createTextNode('}'));}%20else%20if(%20m.type%20==%202%20)%20
  127. {oLi.appendChild(oDoc.createTextNode('@charset%20\''+m.encoding+'\';'));}%20else%20if(%20m.type%
  128. 20==%204%20)%20{oLi.appendChild(oDoc.createTextNode('@media%20'));oLi.appendChild(getMediaList
  129. (oDoc,m));oLi.appendChild(oDoc.createTextNode('%20{%20'));oLi.appendChild(getRulesInBlock
  130. (oDoc,m));oLi.appendChild(oDoc.createTextNode('}'));}%20else%20if(%20m.type%20==%203%20)%20
  131. {oLi.appendChild(oDoc.createTextNode('@import%20url('));var%20oHref%20=%20oDoc.createElement
  132. ('a');oHref.setAttribute('href',m.styleSheet.href);oHref.appendChild(document.createTextNode
  133. (m.href));oLi.appendChild(oHref);oLi.appendChild(oDoc.createTextNode(');'));oLi.appendChild
  134. (getRulesInBlock(oDoc,m.styleSheet,true));}%20else%20if(%20!m.type%20)%20{oLi.appendChild
  135. (oDoc.createTextNode('@unknown%20rule;'));}}return%20oUL;}function%20listSheets(oDoc,oDocument)%20
  136. {var%20oUL%20=%20oDoc.createElement('ol');oUL.className%20=%20'sheetlist';for(%20var%20i%20=%
  137. 200,%20j;%20i%20%3C%20oDocument.styleSheets.length;%20i++%20)%20{oUL.appendChild(describeSheet
  138. (oDoc,oDocument.styleSheets.item(i)));}return%20oUL;}function%20getAllFrames(oWin,oDest,oPar)%20{var%
  139. 20oA,%20oH%20=%20oDest.createElement('h2'),%20li,%20ul%20=%20oDest.createElement
  140. ('ol');oH.appendChild(oDest.createTextNode('Frames'));oPar.appendChild(oH);oPar.appendChild(ul);for(%
  141. 20var%20i%20=%200,%20j;%20i%20%3C%20oWin.frames.length;%20i++%20)%20{li%20=%
  142. 20oDest.createElement('li');oH%20=%20oDest.createElement('h3');li.appendChild(oH);ul.appendChild(li);try%
  143. 20{j%20=%20oWin.frames[i];if(%20j.location%20)%20{oA%20=%20oDest.createElement('a');oA.setAttribute
  144. ('href',j.location.href);oA.appendChild(oDest.createTextNode(j.document.title?
  145. j.document.title:j.location.href));oH.appendChild(oA);}%20else%20{oH.appendChild(oDest.createTextNode
  146. ('Page%20with%20no%20location%20object'));}if(%20j.document%20)%20{li.appendChild(listSheets
  147. (oDest,j.document));if(%20j.frames.length%20)%20{getAllFrames(j,oDest,li);}}}%20catch(e)%20
  148. {oH.appendChild(oDest.createTextNode('Frame%20from%20denied%20domain'));}}}var%20foo%20=%
  149. 20window.open('','_blank');foo.document.write('%3Chtml%3E%3Ctitle%3E%3C\/title%3E%3Cstyle%20type=
  150. \'text\/css\'%3E\n'+'html,%20body%20{%20background:%20%23ddd;%20color:%20%23000;%20}\n'+'a%20
  151. {%20color:%20%2300f;%20}\n'+'a:visited%20{%20color:%20%23909;%20}\n'+'ol,%20ul%20{%20background:%
  152. 20%23bbb;%20list-style-position:%20inside;%20padding:%201px;%20margin:%200.5em%202px;%20}
  153. \n'+'ul,%20ol.sheetlist%20{%20background:%20%2388a;%20}\n'+'ul%20{%20background:%20%23aae;%
  154. 20display:%20block;%20list-style-type:%20none;%20}\n'+'ul.fileroot%20{%20background:%20%23797;%20}
  155. \n'+'ul.medlist,%20ul.medlist%20li%20{%20background:%20transparent;%20display:%20inline;%20margin:%
  156. 200;%20padding:%200;%20}\n'+'ul.medlist%20li::before%20{%20content:%20\',%20\';%20}\n'+'ul.medlist%
  157. 20li:first-child::before%20{%20content:%20\'\';%20}\n'+'li%20{%20background:%20%23ddd;%20padding:%
  158. 201px;%20margin:%202px%202px%202px%201em;%20}\n'+'dl%20{%20padding:%200;%20margin:%200;%
  159. 20}\n'+(%20(%20navigator.product%20!=%20'Gecko'%20)%20?%20'dt,%20dd%20{%20display:%20inline;%
  160. 20white-space:%20pre;%20margin:%200;%20padding:%200%200%200%201em;%20}\n'%20:%20''%20)+'dd%
  161. 20{%20padding-left:%200.3em;%20}\n'+'dd::after%20{%20display:%20block;%20height:%201px;%
  162. 20content:%20\'\';%20}\n'+'\n%3C\/style%3E%3Cbody%3E%3C\/body%3E');foo.document.close();var%20oH
  163. %20=%20foo.document.createElement('h1');oA%20=%20foo.document.createElement('a');oA.setAttribute
  164. ('href',location.href);oA.appendChild(foo.document.createTextNode(foo.document.title=('Stylesheets%
  165. 20for:%20'+(document.title?document.title:location.href))));oH.appendChild
  166. (oA);foo.document.body.appendChild(oH);foo.document.body.appendChild(listSheets
  167. (foo.document,document));if(%20window.frames.length%20)%20{%20getAllFrames
  168. (window,foo.document,foo.document.body);%20}})();
  169.  
  170.  
  171.  
  172. // -------------------------------
  173. // Highlight
  174.  
  175. /*
  176. 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:
  177.  
  178.  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]
  179. */
  180.  
  181. javascript:var%20theLocation='';if(!theLocation){alert('Bookmarklet%20not%20installed%20correctly./n/
  182. nPlease%20follow%20the%20instructions%20given%20on%20the%20page.');}else{var%
  183. 20newScript=document.createElement('script');newScript.setAttribute('src',theLocation);void
  184. (document.body.appendChild(newScript));var%20oWindMeUp%20=%20window.open
  185. ('','synWin','resizable=1,status=0,location=0,toolbar=0,scrollbars=1,top=0,left=0,height='+
  186. (screen.height-59)+',width='+(screen.width-12));}

Report this snippet  

You need to login to post a comment.