Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 348531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:22:24+00:00 2026-05-12T11:22:24+00:00

I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent

  • 0

I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent embedded in it. (I am embedding it rather than hosting it because it’s a very small plugin.)

My problem: after the plugin attaches its event handler to a DOM object, the event triggers an error message that says: “jQuery is not defined.”

Is it a scope issue? Here is my entire script:

   if(unsafeWindow.console){
       var GM_log = unsafeWindow.console.log;
    }


    (function($){
            //HoverIntent
            $.fn.hoverIntent=function(f,g){...}; 
            //Removed the plugin code. You can see it in the link at the bottom 
            //of the post.



    //DOM is ready
    //Fetch all the rows with arrows
    $('.arrow')
        .each(function(){
            $(this).hoverIntent(mouseOver,mouseOut);            
        });

    //mouseOver
    function mouseOver(){
        //THIS IS WHERE THE ERROR HAPPENS
        $(this).click();
    }

    //mouseOut
    function mouseOut(){ //nothing here.
    }

    })(unsafeWindow.jQuery);

It works fine when I copy paste it, removing all GM specific tags, and run it from my console. And this is the plugin I am embedding.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:22:24+00:00Added an answer on May 12, 2026 at 11:22 am

    Does the greasemonkey script run before or after onDOMLoaded? You may need to delay the execution of the script until after the jQuery script is sourced by the parent window, and loaded…

    Edit per comment:

    I don’t see the document.ready bit in your code above, although I see your comment about it… However, your comment is a bit too late in the script to be any use… This might explain:

    (function($){ /* some code here */ })(unsafeWindow.jQuery)
    

    Regardless of what you put in the the /* some code here */ section, if this line is executed before unsafeWindow.jQuery is defined, you’ll still be calling a function on an undefined object…

    Reading the GreaseSpot wiki on unsafeWindow, it suggests the alternative approach of:

    var script = document.createElement("script");
    script.type = "application/javascript";
    script.innerHTML = "(function($){
            //HoverIntent
            $.fn.hoverIntent=function(f,g){...}; 
            //Removed the plugin code. You can see it in the link at the bottom 
            //of the post.
    
    
    
        //DOM is ready
        //Fetch all the rows with arrows
        $('.arrow')
            .each(function(){
                    $(this).hoverIntent(mouseOver,mouseOut);                
            });
    
        //mouseOver
        function mouseOver(){
            //THIS IS WHERE THE ERROR HAPPENS
            $(this).click();
        }
    
        //mouseOut
        function mouseOut(){ //nothing here.
        }
    
    })(jQuery);";
    
    document.body.appendChild(script);
    

    Edit: none of my answers necessarily make sense, though, since you’re using the $ object for a few lines before issue presents itself.. :-S weird.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 223k
  • Answers 223k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There should not be a space between "*" and "/10".… May 13, 2026 at 12:31 am
  • Editorial Team
    Editorial Team added an answer If both sets are sorted one can start at the… May 13, 2026 at 12:31 am
  • Editorial Team
    Editorial Team added an answer I think a better approach is to create an overlay.… May 13, 2026 at 12:31 am

Related Questions

I am writing a simple checkers game in Java. When I mouse over the
I am writing a simple database with web access. I have previous experience with
I am writing a simple Python web application that consists of several pages of
I am writing a simple web app using Linq to Sql as my datalayer

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.