Summarize Web page bookmarklet

//url-escaped, ready for use:
javascript:function%20userSel()%7Bif%20(window.getSelection)%7Btxt%20=%20window.getSelection();%7Delse%20if%20(document.getSelection)%20%20%20%20%7Btxt%20=%20document.getSelection();%7Delse%20if%20(document.selection)%7Btxt%20=%20document.selection.createRange().text;%7Delse%20return;%20%20return%20txt;%7Dfunction%20add(h)%7Bb.appendChild(h);%7Dfunction%20makeTag(t)%7Breturn%20document.createElement(t);%7Dfunction%20makeText(tag,text)%7Bt=makeTag(tag);%20t.appendChild(document.createTextNode(text));%20return%20t;%7Dp=document.location;%20q=document.title.replace(/%5C[[%5E%5C]]*%5C](.*)%20-%20JAG%20JIRA/,%20'$1');%20d=window.open().document;%20d.open();%20d.close();%20b=d.body;%20d.title%20=%20q%20+%20'%20:%20summary%20:%20JIRA';%20u=p+'%5Cn'+q+'%5Cn'+userSel();%20add(makeText('style',%20'textarea%7Bwidth:100%;height:100%;%7D'));%20add(makeText('textarea',%20u));%20void%200

//unescaped, with line breaks
javascript: function userSel() {
if (window.getSelection) {
txt = window.getSelection();
} else if (document.getSelection) {
txt = document.getSelection();
} else if (document.selection) {
txt = document.selection.createRange().text;
} else return;
return txt;
}
function add(h) {
b.appendChild(h);
}
function makeTag(t) {
return document.createElement(t);
}
function makeText(tag, text) {
t = makeTag(tag);
t.appendChild(document.createTextNode(text));
return t;
}
p = document.location;
q = document.title.replace(/[[^]]*](.*) - JAG JIRA/, '$1');
d = window.open().document;
d.open();
d.close();
b = d.body;
d.title = q + ' : summary : JIRA';
u = p + '
' + q + '
' + userSel();
add(makeText('style', 'textarea{width:100%;height:100%;}'));
add(makeText('textarea', u));
void 0;

source

Leave a Reply