Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
    
    <head>
        <meta charset=utf-8 />
        <title>PAEz JS Bin Bookmarkleter</title>
        <script src="https://dl.dropboxusercontent.com/u/3610419/WebPages/JS/uglify.js"></script>
    </head>
    
    <body style="display:none">
<a id="bookmarklet" href="a">Indent Lines for Code</a>
        <script id='code' type='text/bookmarklet'>
            %code%
        </script>
        <script>
            window.addEventListener('load', function() {
                document.body.style.display = "block";
                // Im using Uglify to help make the bookmarklet because all of the js
                // I tried that was meant to do it would keep failing (especially on comments)
                // Uglify hasnt failed yet and you get the bonus of its cool compressor stuff
                // ...Thanks, https://github.com/johnkpaul/bookmarkletify/blob/master/bookmarkletify.js
                var code = document.querySelector('#code').innerText;
              //code = code.replace('window.runnerWindow.proxyConsole','console');
                var bookmarklet = document.querySelector('#bookmarklet');
                var ast = UglifyJS.parse(code);
                ast.figure_out_scope();
                var compressor = UglifyJS.Compressor({
                    sequences: true, // join consecutive statemets with the “comma operator”
                    properties: true, // optimize property access: a["foo"] → a.foo
                    dead_code: true, // discard unreachable code
                    drop_debugger: true, // discard “debugger” statements
                    unsafe: false, // some unsafe optimizations (see below)
                    conditionals: true, // optimize if-s and conditional expressions
                    comparisons: true, // optimize comparisons
                    evaluate: true, // evaluate constant expressions
                    booleans: true, // optimize boolean expressions
                    loops: true, // optimize loops
                    unused: true, // drop unused variables/functions
                    hoist_funs: true, // hoist function declarations
                    hoist_vars: false, // hoist variable declarations
                    if_return: true, // optimize if-s followed by return/continue
                    join_vars: true, // join var declarations
                    cascade: true, // try to cascade `right` into `left` in sequences
                    side_effects: true, // drop side-effect-free statements
                    warnings: true, // warn about potentially dangerous optimizations/code
                    global_defs: {} // global definitions
                });
                ast = ast.transform(compressor);
                code = ast.print_to_string();
                bookmarklet.setAttribute('href', 'javascript:(function(){;' + encodeURI(code) + ';})()');
            })
        </script>
    </body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
PAEzpro
0viewers