Notas de un Peregrino Articulos varios sobre la web, mozilla y firebug

3Dec/10Off

Grooveshark Remote Control

Update: Now the extension is listed and approved in AMO!

Maybe not all of you noticed, but today Grooveshark changed it's UI from the regrettable Flash to a shiny and great HTML interface! YAY!!

Well, being myself a prototyping addict, the first thing I thought was:

"HTML UI + Javascript == Hackability!"

And started coding right from within Firebug the basis of what I wanted to build: A remote controller for Grooveshark!

Before, with the Flash UI, the only way to control Grooveshark was from the page itself. No Javascript APIs were enabled on the player object, so the only way to operate it was the user going there directly. But nowdays, we all browse the web with at least 5 tabs open, and switching to Grooveshark (even for looking at the name of the song being played!) is tiring.

So, enter Jetpack, HTML and Javascript. I was really wanting this feature for a loooooong time, so I took the first chance I had to code it! After some hours inspecting Grooveshark and guessing the API, I ended up with a prototype extension working decently good in Firefox. And is a surprisingly short extension, 85 lines aprox, but with a tremendous UX enhancement for Grooveshark :)

Now, the links and warnings:

WARNING:
As I said before, this is a working prototype. It can screw your tabs. It can do weird things with your Firefox. It can even not work. So you're warned, try this on a new profile or take your chances. Be brave.

Known Issues:

  • Grooveshark now has HTML UI, but in the end is a Flash player. So if you have a flashblocker, add an exception to grooveshark or disable it for testing this addon.
  • It might reload ALL your tabs. This happened randomly, but in different computers. As I used a mixture of unstable software to code this (unstable firefox, unstable jetpack, and 1st day released grooveshark UI) and was coded in like 4hs I still don't know what's the cause.
  • You may have some issues regarding weird combinations of play/pause.
  • I didn't test it on FF3.6, but an alpha tester just told me that deactivating compatibility check in 3.6 it was working.

Functionality:

  • The UI is only shown when a grooveshark tab is open. If you close grooveshark, the remote control goes away until you open the tab again.
  • Once grooveshark is loaded, fill the queue with songs (radio, custom playlist, whatever)
  • Then control the reproduction with the (<<), (>), (||) and (>>) buttons.

Requirements:

Installation:

Is a Restartless addon (as it's coded entirely in Jetpack), so you won't need to restart your browser to test it :)

Further Improvement:

There's loads of things to improve with this addon! I'm planning on maintaining this, so send your comments/complains/etc. to hernan@bipgeeks.com or leave a message in here! Also, a Chromium and maybe Safari and Opera versions are comming too :) .

If you want to help with this, and specially if you're a Designer, I encourage you to contact me in any of the aforementioned ways!

12Dec/09Off

Firebug y Jetpack, juntos otra vez

Ultimamente estuve jugando bastante con un nuevo proyecto de Mozilla Labs: Jetpack. Lo voy a describir brevemente para aquellos que no saben de qué se trata este maravillos nuevo proyecto, pero deberías revisar el sitio de Jetpack si querés aprender más acerca del mismo.

Si alguna vez te preguntaste cómo están hechos todos esos complementos de Firefox, probablemente hayas descubierto (quizás con alguna decepción) que no son tan fáciles de programar. Tenés que aprender un lenguaje llamado XUL para la UI, asimilar un montón de nuevos términos como Overlays, XPI, XPCom... Pero che, no estoy diciendo que todo esto es imposible de aprender (de hecho hay un montón de documentación y tutoriales disponibles), sino que simplemente hay que aprender algo nuevo.

Así que Mozilla pensó sobre esto por un tiempo, y salieron con una idea bastante piola: lo más probable es que vos ya conozcas JavaScript, CSS y HTML. Por qué deberías tener que aprender algo nuevo? Y así nació Jetpack, una nueva forma de programar complementos, en tan sólo un archivo y completamente programados en JavaScript, CSS y HTML.

Firebug y Jetpack

Y qué relación tiene Jetpack con Firebug? Bueno, bastante. Como dicen en el sitio de Jetpack, "para no reinventar la rueda" usaron Firebug para depurar y loguear. Hasta ahora todo perfecto: una manera simple para desarrollar complementos, un lindo depurador... qué más se podría pedir?
Quizás que ambos funcionen juntos ni bien los instalamos?

Como algunos se han dado cuenta, las últimas versiones de Firebug y de Jetpack no funcionan bien juntas de entrada. Esto es porque la versión actual de Jetpack (0.6.2) usa una vieja llamada a la API para comunicarse con Firebug, que cambió en la versión 1.4.3. Al parecer desarrollaron toda la interacción con Firebug usando Firebug 1.4.2, con lo cual nunca se enteraron del cambio en la API de Firebug. Pero a no desesperar! Hay una solución para esto, y es tan simple como cambiar una sóla palabra en una sóla linea de código.

Haciendo que ambos vuelvan a llevarse bien

Nota importante:
Al momento de escribir este artículo el bug abierto para este problema ya está en "Verified and Fixed", lo cual siginifica que el arreglo estará disponible en la próxima versión de Jetpack. Mientras tanto, vas a tener que hacer la siguiente modificación a mano para poder usar Jetpack con un Firebug 1.4.3 o posterior.

Primero que nada, vas a tener que ubicar tu perfil de Firefox. Esto depende de tu sistema, pero acá están algunas de las ubicaciones más comunes:

  • Linux:
    ~/.mozilla/firefox/<profile folder>
  • Mac OS X:
    ~/Library/Mozilla/Firefox/Profiles/<profile folder>
    Ó
    ~/Library/Application Support/Firefox/Profiles/<profile folder>
  • Windows XP:
    C:\Documents and Settings\<Windows login/user name>\Application Data\Mozilla\Firefox\Profiles\<profile folder>
  • Windows 7:
    C:\Users\<Windows login/user name>\AppData\Roaming\Mozilla\Firefox\Profiles\<profile folder>

Si estás usando Firefox 3.6, podés ir a la URL "about:support" y ahí hay un botón que te lleva a la carpeta con tu perfil.

Una vez encontrada la carpeta de tu perfil, vas a tener que ir a esta carpeta que se encuentra dentro del mismo:

extensions/jetpack@labs.mozilla.com/content/js/xul

y editar el siguiente archivo:

firebug-extension.js

Cambiando la línea 19 de:

Firebug.URLSelector.watchBrowser(browser);

A:

Firebug.Activation.watchBrowser(browser);

Guarda el archivo, reinicia Firefox, y voilà, ahora Firebug y Jetpack deberían estar trabajando juntos!

Probando si Firebug está funcionando

Si querés saber si Firebug está funcionando como lo esperado, copiá el siguiente código en la parte de "Develop" en Jetpack:

jetpack.future.import("menu");
jetpack.menu.context.page.add({
    label: "LoguearEsto!",
    command: function(){
        console.log("Firebug está Andando OK");
    }
});

Ahora apretá el botón "Try out this code", habilitá Firebug y actualizá la página. Si todo salio bien, ahora debería haber una nueva entrada en el menú de contexto de la página, llamada "LoguearEsto!". Si hacés click en la misma, y en la consola aparece el texto "Firebug está andando OK", entonces Firebug está andando correctamente.