Delving into Greasemonkey
I’ve had a problem for awhile with FireFox that I just can’t seem to solve. Flash content just doesn’t seem to want to load. It’s not all Flash either. Some of it loads, some doesn’t, and there doesn’t seem to be any rhyme or reason. My temporary solution was to use IETab to switch to IE’s rendering engine, but that wasn’t a real solution. I even uninstalled and re-installed both Flash and FireFox to no avail.
My main annoyance with this problem was listening to new music on Amie Street. I would load up the player’s page only to find the Flash music player not working. Then I would need to view the source code, copy the Flash URL from the source and paste it in the address bar. Once that loaded up, I was able to listen to the music just fine. However, viewing the source and copying and pasting all the time was annoying.
Today, my thoughts turned to Greasemonkey. I had installed it to use the Popup Alt script (so FireFox would display the image’s ALT attribute like IE does). Why couldn’t I have Greasemonkey detect when I went to an Amie Street music player page and redirect me to the appropriate Flash URL? I had never written a Greasemonkey script before, but I knew that they used JavaScript. I made a new script, and also loaded up the source to the Popup Alt script to use for reference. Within a matter of minutes, I had a simple script written that worked perfectly.
// ==UserScript==
// @name Amie Street Playlist
// @namespace AmieStreet
// @description Redirects from Amie Street player page to actual Flash file
// @include http://amiestreet.com/player.php?*
// ==/UserScript==(function() {
if (!(document.getElementById(’amiePlayer’) == null)) {
document.location = ‘http://www.amiestreet.com/static/swf/amie.swf?siteMode=true&’ + document.location.search.replace(/\?/, ”);
}
})();
This script first looks for an element with an ID of “amiePlayer”. If an element exists, it redirects the page to the SWF file (passing the querystring parameters along). Simple and effective. No, it doesn’t solve the root problem of my mystery FireFox+Flash bug, but it does help reduce the annoyance factor and makes Amie Street usable for me again. I just might have to look into writing other Greasemonkey scripts.






Comment by Spyder — April 9, 2008 @ 7:44 pm
Yes, I noticed that clause and did not want to touch it. I hope people really read their Terms of Service and take notice before using Photoshop Express.