~robcee/ more than just sandwiches

Posted
21 July 2009 @ 2pm

Tagged
General

Copy Bookmarklet

I found a cool little feature this morning while poking around in Firebug’s command line code. If you expand the Console’s command line to the large area (using the little up arrow on the right of the command line), you can enter a block of text, nicely formatted. This is probably not news to anyone. Though if you click the little “Copy” button at the bottom of the large command line panel, it trims out the newlines and prepends “javascript: ” on the front of the line, producing text that looks like this:

javascript:var s = document.getSelection(); if (s) { window.open(s); } else { alert(“No selection”); } void(0);

From this:

copy bookmarklet

(Firefox adds %20 for each of the spaces when you save it as a bookmarklet)

The above snippet grabs the currently selected text in a web-page and opens it in a new window. Add it to a bookmarklet of your own on your toolbar and you have a convenient way to open new text in a separate tab. For bonus points, install the keyconfig extension to create a keyboard shortcut (you’ll need to force-install the extension and write a little function to get that to work). Thanks to Neil Lee for the keyconfig tip!


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment

Powered by WP Hashcash