Revision: 7490
Updated Code
at November 5, 2009 09:54 by wizard04
Updated Code
javascript:(function(){function t(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}if(window.location.hostname!='ninjawords.com')window.open('http://ninjawords.com/'+getQ(window.top));else{document.getElementById('q').value = getQ(window.top);Ninjawords.textboxQuery()}})()
//Here it is expanded so you can read it:
javascript:(function(){
function t(f) //get the selected text in frame f
{
try{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
}catch(e){} //if the frame is in another domain
return '';
}
function getQ(f) //get the selected text in frame f and its children
{
//get rid of non-alphanumeric characters and separate words with commas
var q = t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');
var s = '';
for(var i=0; i<f.length; i++) //for each child frame
{
s = getQ(f[i]);
if(s) q += (q?',':'')+s;
}
return q;
}
if(window.location.hostname != 'ninjawords.com') //if not already at ninjawords.com
window.open('http://ninjawords.com/'+getQ(window.top));
else
{
document.getElementById('q').value = getQ(window.top);
Ninjawords.textboxQuery();
}
})()
Revision: 7489
Updated Code
at August 12, 2008 14:15 by wizard04
Updated Code
javascript:(function(){function t(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}window.open('http://www.ninjawords.com/'+getQ(window.top))})();
//Here it is expanded so you can read it:
javascript:(function(){
function t(f) //get the selected text in frame f
{
try{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
}catch(e){} //if the frame is in another domain
return '';
}
function getQ(f) //get the selected text in frame f and its children
{
//get rid of non-alphanumeric characters and separate words with commas
var q = t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');
var s = '';
for(var i=0; i<f.length; i++) //for each child frame
{
s = getQ(f[i]);
if(s) q += (q?',':'')+s;
}
return q;
}
window.open('http://www.ninjawords.com/'+getQ(window.top));
})();
Revision: 7488
Updated Code
at July 31, 2008 09:18 by wizard04
Updated Code
javascript:(function(){function t(f){if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text;return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}window.open('http://www.ninjawords.com/'+getQ(window.top))})();
//Here it is expanded so you can read it:
javascript:(function(){
function t(f) //get the selected text in frame f
{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
return '';
}
function getQ(f) //get the selected text in frame f and its children
{
//get rid of non-alphanumeric characters and separate words with commas
var q = t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');
var s = '';
for(var i=0; i<f.length; i++) //for each child frame
{
s = getQ(f[i]);
if(s) q += (q?',':'')+s;
}
return q;
}
window.open('http://www.ninjawords.com/'+getQ(window.top));
})();
Revision: 7487
Updated Code
at July 31, 2008 09:13 by wizard04
Updated Code
javascript:(function(){function t(f){if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text;return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}window.open('http://www.ninjawords.com/'+getQ(window.top))})();
//Here it is expanded so you can read it:
javascript:(function(){
function t(f)
{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
return '';
}
function getQ(f)
{
var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');
var s='';
for(var i=0;i<f.length;i++)
{
s=getQ(f[i]);
if(s) q += (q?',':'')+s;
}
return q;
}
window.open('http://www.ninjawords.com/'+getQ(window.top));
})();
Revision: 7486
Updated Code
at July 25, 2008 22:25 by wizard04
Updated Code
javascript:(function(){function t(f){if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text;return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}window.open('http://www.ninjawords.com/'+getQ(window.top))})();
Revision: 7485
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 25, 2008 21:46 by wizard04
Initial Code
javascript:(function(){function getSel(frm){var str=frm.getSelection().toString().replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,"").replace(/[^a-z0-9-]+/ig, ",");var s="";for(var i=0;i<frm.length;i++){s=getSel(frm[i]);if(s)str+=(str?",":"")+s;}return str;}var q=getSel(window.top);if(q)window.open("http://www.ninjawords.com/"+q);})();
Initial URL
Initial Description
Select some text, click the bookmarklet, and the definition(s) will open up in [Ninjawords](http://www.ninjawords.com).
[Ninjawords](javascript:(function(){function%20t(f){try{if(f.getSelection)return%20f.getSelection().toString();if(f.document.selection)return%20f.document.selection.createRange().text}catch(e){}return%20''}function%20getQ(f){var%20q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig,%20',');var%20s='';for(var%20i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return%20q}if(window.location.hostname!='ninjawords.com')window.open('http://ninjawords.com/'+getQ(window.top));else{document.getElementById('q').value%20=%20getQ(window.top);Ninjawords.textboxQuery()}})() "Drag this into your bookmarks!")
Initial Title
Ninjawords Bookmarklet
Initial Tags
javascript
Initial Language
JavaScript