Skip to content

Instantly share code, notes, and snippets.

@amit
Created March 22, 2011 23:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amit/882351 to your computer and use it in GitHub Desktop.
Save amit/882351 to your computer and use it in GitHub Desktop.
Expanded Quix bookmarklet
javascript:Quix();function Quix() {
var e=encodeURIComponent; // shortcut for the function name
var t=window.getSelection ? window.getSelection():
(document.getSelection? document.getSelection(): (document.selection ? document.selection.createRange().text:'')); // Get selection or empty string
var c=window.prompt('Quix: Type `help` for a list of commands:');
if(t!='') {
if(c) {
c+=' '+t; // append selection to typed text
}
else {
c=''+t; // use the text in prompt
}
}
if(c) {
var u='http://quixapp.com/go/?c=' + e(c) +
'&t=' + (document.title?e(document.title):'') +
'&s=' + '&v=080' + '&u=' +
(document.location?e(document.location):'');
d=''+document.location;
if(d.substr(0,4)!='http') {
window.location=u+ '&mode=direct';
}
else {
heads=document.getElementsByTagName('head');
if(c.substring(0,1)==' ') {
var w=window.open(u+'&mode=direct');
w.focus();
}
else if (heads.length==0){
window.location= u + '&mode=direct';
}
else {
q=document.getElementById('quix');
if(q) {
q.parentNode.removeChild(q);
}
sc=document.createElement('script');
sc.src=u;
sc.id='quix';
sc.type='text/javascript';
void(heads[0].appendChild(sc));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment