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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:24:11+00:00 2026-05-23T17:24:11+00:00

I know Greasemonkey scripts are automatically wrapped in anonymous functions isolated in some way

  • 0

I know Greasemonkey scripts are automatically wrapped in anonymous functions isolated in some way in order to prevent them conflicting with scripts in the page.

Does the same happen with Chrome user-scripts?

  • 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-23T17:24:12+00:00Added an answer on May 23, 2026 at 5:24 pm

    Yes, Greasemonkey scripts are normally wrapped in an anonymous function. And, Chrome userscripts apparently are too.

    But, more importantly, Greasemonkey scripts are usually1 wrapped in an XPCNativeWrapper sandbox, while Google Chrome converts userscripts into extensions, and they operate in an arena that Google calls an “isolated world”2.

    So, you don’t need to wrap your script code in anonymous functions for security purposes, they’re already protected.

    Just beware that:

    1. If you inject code directly into the page (create a <script> tag), then that code can be seen by the page’s JS.
    2. If you use unsafeWindow, then the page could theoretically follow it back and gain slightly elevated privileges.

    The risk is very low, and I haven’t been able to find any documented exploits in the wild.

    ~~~
    Bottom line, scripts are isolated to different degrees in both browsers. (And not merely by being wrapped in anonymous functions.)

    Greasemonkey has a nice set of privileged features available, in Firefox. While userscripts in Chrome are much more restricted.

    However, much of GM’s functionality is restored to Chrome via use of the Tampermonkey extension.


    1 As of Greasemonkey version 1.0 (August 24, 2012), the sandbox is controlled by the @grant directive. If the script runs with (or defaults to) @grant none, then the sandbox isn’t used. The script merely runs in a private scope and the normal GM_, API functions will not work.

    2 Doesn’t that sound so much bigger/nicer than some nasty sandbox? (^_^)

    .

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

Sidebar

Related Questions

I'm interested in writing some Chrome compatible Greasemonkey scripts, but I'm finding that there
Is there a way I can use Greasemonkey to selectively remove scripts on a
I don't know greasemonkey but I think it is a way to script or
I didn't find a way to debug Greasemonkey scripts with the Firebug extension. Does
Know of any good libraries for this? I did some searches and didn't come
I need some advice. I have a web page and want to extend it's
I'm trying to add some jQuery stuff to Gmail using a GreaseMonkey script. Adding
I am looking for a quick way to grab some data off of one
I have my greasemonkey script scanning every page i visit for a specific string.
I'm getting into user scripts at the moment. I know Opera is compatible with

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.