Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Twily 2015
- Description: Optional patch for using "!i" before (in front of) the search query string
- Original: http://twily.info/firefox/homepage-sidebar.html
- Instructions: Replace the original 'handleQuery' function with the code below
- */
- function handleQuery(e,q) { // Handle search query
- var key=e.keyCode || e.which;
- if(key==13) { // Enter
- //var x=q.lastIndexOf("!");
- var x=q.indexOf("!");
- //if(x!=-1 && x>=q.length-2) {
- if(x==0) {
- for(var i=0;i<search.length;i++) {
- //if(search[i][0]==q.substr(x)) { // Find "*!i"
- if(search[i][0]==q.substr(0,2)) { // Find "!i*"
- //window.open(search[i][1]+q.substr(0,x).replace(/&/g,"%26"));
- window.open(search[i][1]+q.substr(2).replace(/&/g,"%26"));
- $('q').value="";
- $('q').focus();
- return true;
- }
- }
- // Invalid "!i", use default
- //window.open(ss+q.substr(0,x).replace(/&/g,"%26"));
- window.open(ss+q.substr(2).replace(/&/g,"%26"));
- } else {
- // "!i" where not specified, use default
- window.open(ss+q.replace(/&/g,"%26"));
- }
- $('q').value="";
- $('q').focus();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement