This will get you a good portion of the way there.
javascript:function htmlEscape(s) {
s=s.replace(/&/g,'&
s=s.replace(/>/g,'>');
s=s.replace(/</g,'<');
return s;
}
function linkEscape(s) {
s=s.replace(/&/g,'&');
s=s.replace(/"/,'"');
return s
}
h = '<a href="'
+ linkEscape(location.href)
+ '">' + htmlEscape(document.title) + '</a>';
with(window.open().document) {
write(h+'<form name=f>
<textarea name=a rows=5 cols=80 wrap=hard>'
+htmlEscape(h)+'</textarea></form>');
close();
f.a.select();
}
void 0;
I leave it to you to grok the rest of the data out of the page in question, but here's a clue there as well:
javascript:(function() {
var a = { },
b =[], i, e, c, k, d, s =
"<table border=1>
<thead>
<tr><th>#</th>
<th>Tag</th>
<th>className</th>
</tr>
</thead>";
for (i = 0;
e = document.getElementsByTagName("*")[i];
++i)
if (c = e.className) {
k = e.tagName +
"." + c;
a[k] = a[k] ? a[k] + 1 : 1;
}
for (k in a) b.push([k, a[k]]); b.sort();
for (i in b) s +=
"<tr><td>" + b[i][1]
+ "</td><td>"
+ b[i][0].split(".").join("</td><td>")
+ "</td></tr>"; s += "</table>";
d = open().document; d.write(s); d.close();}
)
Be aware of the maximum length of bookmarklets in your browser of course, and make sure to unwrap the code above onto single lines in your bookmarklet entry field. I have purposely wrapped these here to eliminate the possibility of rogue '+' signs appearing in there from PerlMonks wrapping code itself.
Good luck..
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.