Google Chrome Search Bar

Third-party modifications and add-ons, Apps and Clients

Moderator: moderators

Google Chrome Search Bar

Postby ytechie » Wed Dec 14, 2011 12:23 am

I am currently working on being able to search in subsonic directly from the Google Chrome search bar. (Officially called the Omnibox.)

Basically I want to add a search engine to Chrome so that I can open a new tab and quickly search for a song, artist or album.

I know it can be done using the REST api, but that returns XML.

What I need to know is how to search using Subsonic's search implementation through the URL in a HTTP GET request.

Any ideas? :)
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Google Chrome Search Bar

Postby ytechie » Wed Dec 14, 2011 3:27 am

So here is what I have so far:
I made a new file called googleSearch.jsp and placed it in the webapp directory.

Here is the file's contents:

Code: Select all
<html>
<head>
<title>Google Chrome Search</title>
<script type="text/javascript">
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var url = unescape(window.location.href).replace(/\+/g," ");
  var results = regex.exec( url );
  if( results == null )
    return "";
  else
    return results[1];
}
function passpar() {
document.getElementById("query").value = gup('q');
document.forms["searchForm"].submit();
}
</script>
</head>
<body onload="passpar()">
<div style="display:none">
<form method="post" action="search.view" name="searchForm">
    <table>
      <tr>
      <td>
         <input type="text" name="query" id="query" size="28" value="">
      </td>
        <td>
         <input type="submit" id="submitform" onclick="passpar()">
      </td>
      </tr>
   </table>
</form>
</div>
</body>
</html>


Basically it parses the url and sends the "q" parameter's value to the textbox. Then it submits the form.
So the url would be: [subsonic]/googleSearch.jsp?q=[searchString]

The next step is to set up a chrome search engine. The url should be [subsonic]/googleSearch.jsp?q=%s

Here is the problem: It searches fine, but it is only the search window. It does not have all the frames.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York


Return to Mods, Apps and Clients

Who is online

Users browsing this forum: No registered users and 2 guests