Created
March 22, 2011 23:47
-
-
Save amit/882351 to your computer and use it in GitHub Desktop.
Expanded Quix bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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