My favorites
|
Sign in
translate-bookmarklet
Translates a selected piece of text in the browser to your language
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
r3
Source path:
svn
/
trunk
/
bin
/
makebookmarklet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
my $src = do { local $/; <> };
# Zap the first line if there's already a bookmarklet comment:
$src =~ s{^// ?javascript:.+\n}{};
my $bookmarklet = $src;
for ($bookmarklet) {
s{^\s*//.+\n}{}gm; # Kill comments.
s{\t}{ }gm; # Tabs to spaces
s{[ ]{2,}}{ }gm; # Space runs to one space
s{^\s+}{}gm; # Kill line-leading whitespace
s{\s+$}{}gm; # Kill line-ending whitespace
s{\n}{}gm; # Kill newlines
}
# Escape single- and double-quotes, spaces, control chars, unicode:
$bookmarklet = "javascript:" .
uri_escape_utf8($bookmarklet, qq('" \x00-\x1f\x7f-\xff));
print "// $bookmarklet\n" . $src;
# Put bookmarklet on clipboard:
`/bin/echo -n '$bookmarklet' | /usr/bin/pbcopy`;
Show details
Hide details
Change log
r2
by dalmaer on Apr 24, 2008
Diff
initial import
Go to:
/trunk/bin
/trunk/bin/makebookmarklet
/trunk/bookmarklet
...marklet/translate-bookmarklet.js
/trunk/bookmarklet/translate.js
/trunk/server
/trunk/server/protowin.js
/trunk/server/themes
/trunk/server/themes/black_hud
/trunk/server/themes/black_hud.css
...rver/themes/black_hud/bottom.png
...themes/black_hud/button_over.png
...es/black_hud/button_unactive.png
...ver/themes/black_hud/content.png
.../server/themes/black_hud/top.png
/trunk/server/themes/window.css
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1006 bytes, 34 lines
View raw file
File properties
svn:executable
*
Hosted by