Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Bookmarklet maker / Favelet maker</h1>
<p>
<label for="txar">%code%:</label>
<button>*)
	<dl>
		<dt>Due "inline" nature of bookmarklet, you shall:
		<dd>- not use line commnets (<strong>//</strong>) ever (or even better do not comment at all)
		<dd>- use semicolons (<strong>;</strong>) between statements
	</dl>
</button>
<textarea cols="70" rows="30" wrap="off" id="txar" onkeyup="hrefize()">
alert('Hello, ' + document.title);
/*
This code will be straightforwardly inlined, so:
-	semicolons everywhere
-	no inline comments
Also, no transforms, sanitizing and so on will be made.
*/ 
</textarea>

<p>
<label for="titlel">%title%:</label> 
<input id="titlel" type="text" onkeyup="hrefize()" value="Hello" />

<p>
<label>Your Resulting Bookmarklet:</label>
<span data-note="just wrapper for innerHTML retrieval" class="the_wrapper"><a
	id="lnk" title="here will be title" href="#here_will_be_generated_javascript_uri"
>here will be title</a></span> – right click &amp; bookmark it OR drag it into bookmark toolbar.
<p><label for="check">Actual result:</label> &lt;a
	href="javascript:(function(){inlinized <label for="txar">%code%</label>})();"
	title="<label for="titlel">%title%</label>"&gt;<label for="titlel">%title%</label>&lt;/a&gt;
<p><textarea id="check" rows="5"></textarea>
<hr>
<h2>Some bookmarklets</h2>
<dl class="bmls">
 <dt><a id="set_body_width" href="javascript:(function(){document.getElementsByTagName('html')[0].style.width=document.getElementsByTagName('body')[0].style.width=prompt('body%20width?','2000px')})();">Set body width</a>
	 <dd>test pages display in viewport larger than yours.
 <dt><a id="reformat_and_pretty_print_javascript_source" title="JS prettyPrint" href="javascript:(function(){var pre = document.getElementsByTagName('pre'); if( !pre || !pre.length ) throw 'No PRE tag found'; pre = pre[0]; if ( pre.className.indexOf('prettyprinted') > -1 ) throw 'You shall not overprettify!'; pre.className = 'prettyprint lang-js'; pre.style.border = 'none'; pre.style.padding = '0px'; pre.style.tabSize = '4'; pre.style.MozTabSize = '4'; var prettify_css = document.createElement('link'); prettify_css.type = 'text/css'; prettify_css.rel = 'stylesheet'; prettify_css.href = 'https://google-code-prettify.googlecode.com/svn/trunk/styles/sunburst.css'; prettify_css.href = 'https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css'; var beautify = document.createElement('script'); beautify.type = 'text/javascript'; beautify.src = 'http://jsbeautifier.org/beautify.js'; beautify.onload = function () { pre.innerHTML = js_beautify(pre.innerHTML, {jslint_happy:1,indent_size:1,indent_char:'\t'}); document.body.appendChild( prettify_js ); document.body.appendChild( prettify_css ); }; var prettify_js = document.createElement('script'); prettify_js.type = 'text/javascript'; prettify_js.src = 'https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js'; prettify_js.onload = function () { prettyPrint(); }; document.body.appendChild( beautify );})();">JS prettyPrint</a>
 	<dd>when viewing source, fire up <a href="http://jsbeautifier.org/">jsbeautifier.org</a>'s magic and then colour it with <a href="https://google-code-prettify.googlecode.com/svn/trunk/README.html">google-code-prettify</a>
</dl>
<h2>Some libraries</h2>
<dl class="bmls">
 <dt>Slayeroffice Favelet Suite
 	<dd><a href="http://slayeroffice.com/?c=/content/tools/suite.html">http://slayeroffice.com/?c=/content/tools/suite.html</a>
 <dt>Squarefree bookmarklet library
 	<dd><a href="https://www.squarefree.com/bookmarklets/">https://www.squarefree.com/bookmarklets/</a>
 <dt>Pixy's "Let's Favelets"
 	<dd><a href="http://www.pixy.cz/pixylophone/favelets/">http://www.pixy.cz/pixylophone/favelets/</a>
 <dt>Kevin Smith's "Favelets - Some Folks Call Them Bookmarklets"
 	<dd><a href="http://centricle.com/tools/favelets/">http://centricle.com/tools/favelets/</a>
</dl>
              
            
!

CSS

              
                body{background-color:#333;color:#ccc}
h1,h2,h3,em,strong,th,thead,label,dt,legend,caption{color:#fff}
a:link{color:#6ff}a:visited{color:#9f3}label:hover,a:hover{background-color:#000}
html *{font-family:"Courier New",monospace}

dt a,
#lnk
{
	border: outset black;
	background-color: black;
	padding: 5px; 
	display: inline-block;
	
}

:target {
	border-color: red !important;
	font-size: 2em;
	padding: 0.2em;
}

textarea {
	width: 99%;
	-moz-tab-size: 4;
	tab-size: 4;
}

#titlel {
	width: 50%;
}
button {
	background-color: transparent;
	color: #ccc;
}
button dl {
	display: none;
}
button:focus {
}
button:focus dl {
	display: block;	
}
h1, h2 {
	font-size: 1em;
	font-weight: normal;
}
.the_wrapper {
	border: 3px solid yellow;
	display: inline-block;
}
              
            
!

JS

              
                var txar = document.getElementById('txar');
var lnk = document.getElementById('lnk');
var check = document.getElementById('check');
var titlel = document.getElementById('titlel');

hrefize();
// txar.focus();

function hrefize()
{	var src = txar.value
		.replace( /\n/g, ' ' )
		.replace( /\s\s*/g, ' ' )
		.replace( /^ | $/g, '');
;	var pref = '(function(){'
;	var suff = '})();'
;	if ( src.indexOf( pref ) == 0 )
	{	pref = ''
	;	suff = ''
	}
;	lnk.href 
	=	'javascript:'
	+	pref
  	+	src
  	+	suff
;	lnk.title = lnk.innerHTML = titlel.value
;	check.value = lnk.parentNode.innerHTML
}
              
            
!
999px

Console