$script_src = "(function(){\n\n\n".
" -- INSERT YOUR CODE HERE --".
"\n\n\n})();";
if($_GET['reset']){
setcookie('script',false);
} else {
if($_GET['script']){
$script_src = stripslashes($_GET['script']);
setcookie('script',$script_src, time()+60*60*24*30);
} else {
if($_COOKIE['script']){
$script_src = stripslashes($_COOKIE['script']);
}
}
}
// HTML escape this version:
$script = $script_src;
$script = str_replace('&','&',$script);
$script = str_replace('<','<',$script);
$script = str_replace('>','>',$script);
?>
Bookmarklet Converter
Javascript Bookmarklet Generator
Write your Javascript code here:
Generated Bookmarklet:
// URL-escape this version:
$script = str_replace('%','%25', $script_src);
$escapes = array(
"\r" => '',
"\n" => '',
"\t" => '',
'/' => '%2F',
'#' => '%23',
'?' => '%3F',
'*' => '%2A',
'!' => '%21',
"'" => '%27',
'"' => '%22',
'>' => '%3E',
'<' => '%3C'
);
foreach($escapes as $key => $val){
$script = str_replace($key,$val,$script);
}
$script = 'javascript:'.$script;
echo "Link";
?> (click it to test, or drag it to your bookmarks to save it)
Generated Bookmarklet Code:
Reset (start new script)
Download PHP source (for this page)