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 6840873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:53:50+00:00 2026-05-26T23:53:50+00:00

From earlier SO post i found that for Greasemonkey script to be compatible with

  • 0

From earlier SO post i found that for Greasemonkey script to be compatible with Chrome we have to create script element for jQuery http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script

If my current userscript which works fine in firefox is as follows. How should I modify it to include the above method and still call the function on onload? Where do I place the current code in the solution suggested in earlier posts?

// ==UserScript==
// @name           Google+
// @version        1.1
//
// 
// @include        http://plus.google.com/*
// @include        https://plus.google.com/*
//
// @require        https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js


$(function()
   {

   $(window).bind('load', function()
   {
           console.log("Hi Condition is very bad!")

           $('<div id="vdiv"></div>').prependTo('#contentPane');
           $('<img>',
           {
           src: 'http://icons.iconarchive.com/icons/aha-soft/security/16/key-icon.png',
           alt: 'Key',
           title:'Key',
           click: function(){
           alert($(this).attr('title'));
           var vtext = jQuery('div.f-ba-mg iframe').contents().find('body').text().trim();
           alert(vtext);
           }
           })
           .css({
           cursor: 'pointer',
           border: '1px solid black',
           backgroundColor: 'white'
           })
           .appendTo('#vdiv');
   });
   });
  • 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-26T23:53:51+00:00Added an answer on May 26, 2026 at 11:53 pm

    Ehm, you can be pretty sure the script executes after the ondomready-event, that’s greasemonkey’s normal execution time (chrome offers an earlier execution time, but that’s just a special option). So there’s no need to run it at onload. So you can actually put it anywhere, as long as you load jQuery beforehand.

    The solution by Erik would work by making 1 init-function (what would normally run at .ready()), and use addJquery(init-function);

    Btw, my method for including jQuery is adding it into the script itself, since otherwise it has to be loaded for every page (which is a slowdown), so I have a minified version of jQuery in the script and some other solutions, see http://userscripts.org/scripts/review/52341
    (btw, I came in as a maintainer, the code is far from perfect).

    Solutions there:

    1.) there are some comment lines on top of jQuery, followed by an adapted and modified version of jQuery 1.4.4 (since there are slight differences between the greasemonkey environment and the normal document scope).

    2.) Just above those lines, I’m using localStorage to recreate some of greasemonkey’s functions on Chrome.

    3.) unsafeWindow in greasemonkey is about equal to window in chrome, but only for functions the browser itself offers (others are blocked by chrome, since they are unsafe). Not using a lot, only unsafeWindow.console.log() and some less important thingies afaik.

    But for your case, erik’s method works too:

    $(function(){
      $(window).bind('load', function(){
        ...
      });
    });
    

    to

    addJquery(function() {
      ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution from an earlier post that was kindly provided by Dimitre
From an earlier post about trying to improve my sites performance I have been
We have an existing PHP page (from an earlier project) which could be described
I have this query to get the first result I want from this post
Apparently I was asking the wrong question in my earlier post. I have a
Possible Duplicate: Prevent Back button from showing POST confirmation alert I have used the
This question is continuation from my earlier post titled selecting digits from regular expression.
Following up from an earlier question on extracting the n'th regex match , I
Following on from my earlier question , I am still having issues with loading
Ok - this is in continuation from my earlier question about sending an email

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.