Browser Extension, Firefox, Google-Music-Search, Google-Open-Storage-Search, Javascript

Firefox Extension – Google-Music-Search v0.2

Firefox Google-Music-Search


Firefox Google-Music-Search running on Crunchbang Linux


Google Music Search provides a simple way to search for music and files on google.com. There are two different types of queries to run: one to search for music files, and one to search for anything else stored in open indexed storage. Both open a tab in the browser and display search results from google.com. Firefox Google Music Search extension is based the Chrome Google Music Search and Chrome Open Storage Search extensions.

package.json

{
  "name": "google-music-search",
  "fullName": "Google-Music-Search",
  "id": "jid1-mIB68YB7TCOYZg",
  "description": "Makes searching for music and files on Google simple",
  "author": "Timothy Tocci - timothytocci.com",
  "homepage":"https://timothytocci.com/",
  "license": "MPL 2.0",
  "version": "0.2"
}

main.js


var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");
var data = require("sdk/self").data;
var widget = widgets.Widget({
  id: "google-music-search",
  label: "Google Music Search",
  contentURL: data.url("google.png"),
  onClick: function() {
	searchdialog.show();
  }
});
var searchdialog = require("sdk/panel").Panel({
  width:480,
  height:272,
  contentURL: data.url("searchdialog.html")
});
var helpdialog = require("sdk/panel").Panel({
  width:640,
  height:480,
  contentURL: data.url("helpdialog.html")
});
searchdialog.port.on("doquery", function(url) {
  console.log(url);
  hidedialog();
  tabs.open(url);
});
function hidedialog(){
	searchdialog.hide();
}
searchdialog.port.on("helpclicked", function() {
    showhelp();
});
function showhelp(){
	helpdialog.show();
}
function closehelp(){
	helpdialog.hide();
}
helpdialog.port.on("gohome", function() {
	console.log("gohome");
    tabs.open("https://timothytocci.com/");
});
helpdialog.port.on("gocmusic", function() {
	console.log("gocmusic");
    tabs.open("https://timothytocci.com/2013/02/01/google-chrome-extension-google-music-search-an-omnibox-extension/");
});
helpdialog.port.on("gocoss", function() {
	console.log("gocoss");
    tabs.open("https://timothytocci.com/2013/02/03/google-chrome-extension-google-open-storage-search-an-omnibox-extension/");
});

helpdialog.html


<html>
    <head>
        <style>
            body {
                background-color: white;
            }
            
            input {
                height: 30px;
                width: 450px;
            }
			#home{
				color:blue;
				text-decoration:underline;
				cursor:hand;
			}
			#cmusic{
				color:blue;
                text-decoration:underline;
                cursor:hand;
			}
			#coss{
				color:blue;
                text-decoration:underline;
                cursor:hand;
			}
            #intro{
            	font-size: large;
            }
			.queries{
				font-size:large;
				font-weight:bold;
			}
			.qlist li{
				list-style: url(google.png);
			}
            .blue {
                color: blue;
            }
            
            .red {
                color: red;
            }
            
            .orange {
                color: orange;
            }
            
            .green {
                color: green;
            }
        </style>
    </head>
    <body>
        <center>
            <h1><span class="blue">G</span><span class="red">o</span><span class="orange">o</span><span class="blue">g</span><span class="green">l</span><span class="red">e</span>-<span class="blue">M</span><span class="red">u</span><span class="orange">s</span><span class="blue">i</span><span class="green">c</span>-<span class="blue">S</span><span class="red">e</span><span class="orange">a</span><span class="blue">r</span><span class="green">c</span><span class="red">h</span></h1>
            <p id="intro">
                Google Music Search provides a simple way to search for music and files on google.com. 
				There are two different types of queries to run: one to search for music files, and one to search for anything stored in open indexed storage. 
				Both open a tab in the browser and display search results from google.com. 
				Firefox Google Music Search extension is based the <a id="cmusic">Chrome Google Music Search</a> and <a id="coss">Chrome Open Storage Search</a> extensions. 
				Google Music Search was written by <a id="home">Timothy Tocci</a>.
            </p>
        </center>
        <p>
            To search for music files simply provide a band or artist name press the Music Search Button. To search for other filetypes; you must first specify the filetypes you are looking for. Filetypes can be ORed together using the pipe (|) character. After the filetypes you must enter a space. Anything before the first space in the query is considered the filetype(s). Then enter the query term for the file(s) you are searching for and press the Open Storage Search button.
        </p>
		<h4>Examples</h4>
		<ul class="qlist"><li><span class="queries">gif|jpg|png homecoming queen</span></li>
		<li><span class="queries">flv|mov|mp4 first steps</span></li>
		<li><span class="queries">torrent sometorrentfile</span> <-- May also act as a torrent weasel (depends on seed host)</li></ul>
    </body>
    <script type="text/javascript">
        window.onload = function(){
            var homelink = document.getElementById("home");
            homelink.addEventListener("click", function(){
                addon.port.emit("gohome","");
            }, false);
			
			var cmusiclink = document.getElementById("cmusic");
            cmusiclink.addEventListener("click", function(){
                addon.port.emit("gocmusic","");
            }, false);
			
			var cosslink = document.getElementById("coss");
            cosslink.addEventListener("click", function(){
                addon.port.emit("gocoss","");
            }, false);
        }
    </script>
</html>


searchdialog.html


<html>
    <head>
        <style>
            body {
                background-color: white;
            }
           
            input {
                height: 30px;
                width: 450px;
            }
            
            #goo {
                padding-top: 20px;
            }
			.blabels{
				font-size:large;
			}
        </style>
        
    </head>
    <body>
        <center>
            <div id="goo">
                <img src="google_logo_front.png"/>
            </div>
            <br/>
            <div>
                <input name="query" id="query" type="text" align="center" placeholder="enter a bandname or filetype and query"/>
                <br/>
                <button id="music">
                	<span class="blabels">Music Search</span>
                </button>
                <button id="storage">
                	<span class="blabels">Open Storage Search</span>
                </button>
				<button id="help">
                    <span class="blabels">Help/About</span>
                </button>
            </div>
        </center>
    </body>
	<script type="text/javascript">
           window.onload = function () {
                var btnmusic = document.getElementById("music");
                btnmusic.addEventListener("click", function(){
                    var input = document.getElementById("query");
                    var text = input.value;
					if(input.value == ""){return}
                    var query = 'intitle:index.of +?last modified? +?parent directory? +(mp3|wma|ogg|wav) +"' + text + '" -htm -html -php -asp -jsp -"Passwords"';
                    doquery(query);
                }, false);
                var btnstorage = document.getElementById("storage");
                btnstorage.addEventListener("click", function(){
                    var input = document.getElementById("query");
					if(input.value == ""){return}
                    var temp = input.value.split(" ", 2);
                    var filetype = temp[0];
                    text = temp[1];
                    var query = 'intitle:index.of +?last modified? +?parent directory? +(' + filetype + ') +"' + text + '" -htm -html -php -asp -jsp -"Passwords"';
                    doquery(query);
                }, false);
				
				var btnhelp = document.getElementById("help");
                btnhelp.addEventListener("click", function(){
					addon.port.emit("helpclicked");
				},true);
					
            }
            function doquery(query){
                url = "https://www.google.com/search?q=" + encodeURIComponent(query);
                addon.port.emit("doquery", url);
            }
        </script>
</html>

Click to Install Most Recent Version

Advertisement
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s