views:

269

answers:

2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; 
<html> 
  <head> 
    <title>Hijack Example</title> 
    <script type="text/javascript" src="./jquery-1.2.1.js"></script> 


    <script type="text/javascript"> 

    var preventDefaultAction = true; //TODO-U
    var cmdSpecStr = 'C-l'; //TODO-U

...and that's where its getting stuck. Soo frustrating. Is there actually anything wrong with my syntax?

Btw, the complaint its giving me is

Uncaught ReferenceError: cmdSpecString is not defined

+6  A: 

I've used Greasemonkey frequently, but only in Firefox. Immediately I notice a few things:

  1. Greasemonkey scripts are written in pure JS, using the syntax of this example. You're writing in HTML.
  2. Following from pure JS, there is no (direct) way to include another script.
  3. cmdSpecStr does not match cmdSpecString.
  4. There is no mention of cmdSpecString in the code you've posted.

EDIT: As noted, you can include other scripts using the DOM method, though it's usually not worth it.

Matthew Flaschen
Wow, I feel stupid. Thanks.
Joe
A: 

Regarding including other scripts, it's possible by adding script tags into DOM. Here's an example of adding jQuery into a greasemonkey script. http://joanpiedra.com/jquery/greasemonkey/

Detect