[Greasemonkey] Redirecting

Tod Beardsley todb at planb-security.net
Sun Aug 13 09:46:15 EDT 2006


On 8/12/06, Adam Zimilover <azcool91 at gmail.com> wrote:
> and err... how would you do that (as you can see im VERy new to this)

Everyone was once.

You should probably get familiar with the basics by reading through
and playing with the examples at
http://www.diveintogreasemonkey.org/toc/. If you need a primer on
javascript, there are a million and one sites that cover that (is
there one or two in particular that people reference? I personally
started with Javascript Bible).

Matt suggested:

> To prevent looping, simply check the current location

The easiest way to accomplish this in GM is an @include statement.
Below, the redirect only happens if you're on http://www.yahoo.com/.

// ==UserScript==
// @name           Move from yahoo to google
// @namespace      http://planb-security.net/examples
// @description    Favor Google over Yahoo, for whatever reason
// @include        http://www.yahoo.com/
// ==/UserScript==

(function () {
	window.location = 'http://www.google.com/';
})();

-- 
planb-security.net | ICQ: 335082155 | Note: Due to Google's privacy
policy <http://tinyurl.com/5xbtl> and the United States' policy on
electronic surveillance <http://tinyurl.com/muuyl>, please do not
IM/e-mail me anything you wish to remain secret or private.


More information about the Greasemonkey mailing list