views:

42

answers:

1

The reason I want to do this is that I'm writing a script for meebo.com that involves changing the background and replacing some pictures with css. I'd like to add links to it from other sites (namely Gmail, Google Calendar, etc.) Is it possible to accomplish this with one Greasemonkey script? (I think this is a general enough question to exclude my actual code but if it would help, just leave a comment saying so.)

+1  A: 

Well, I think the conventional method would be to write two scripts, one that only @include's meebo.com (and changes the background image) and another that @include's http://* or whatever set of other URLs (and adds a link to meebo).

But if you're set on writing only a single script, you could use a series of if statements to accomplish the same effect. That would look something like this:

// @include        http://*
// ==/UserScript==
if (window.location.hostname.match(/meebo\.com/) {
    //change background images and do other meebo.com specific actions
} else if (window.location.hostname.match(/google\.com/) {
    //add a link to the DOM (or some other Google specific action)
}
npdoty
Thanks, works great.
sfarbota