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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:05:21+00:00 2026-06-12T03:05:21+00:00

I have a site running in a few environments on different URLs (i.e. dev.mysite.com

  • 0

I have a site running in a few environments on different URLs (i.e. dev.mysite.com, qa.mysite.com, uat.mysite.com, etc).
There is a Greasemonkey script (myGM.user.js) at each of the environments but its version can be different and depending on the environment a different web service needs to be called to get some data.

In my user script, I would like to get the URL from which that user script was originally installed, so I could then extract the host and use it as a prefix for my web service URL.

For example, if my script is installed from
    http://dev.mysite.com/myGM.user.js,
I want to get
    http://dev.mysite.com/myGM.user.js,
extract
    http://dev.mysite.com/
from it and call
    http://dev.mysite.com/myWebService/getData
for data.

What’s the easiest way to accomplish that? Thanks!

  • 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-06-12T03:05:22+00:00Added an answer on June 12, 2026 at 3:05 am

    I’ve ended up adding an ASPX page (could be PHP or whatever) to the same folder as myGM.user.js. It simply determines the current host (server-side) and outputs it as text.

    So if you browsed to
    http://dev.mysite.com/getHost.aspx
    the response would be
    http://dev.mysite.com/
    And if you browsed to
    http://uat.mysite.com/getHost.aspx
    response would be
    http://uat.mysite.com/

    Then, in my myGM.user.js I’ve added
    // @resource rootUrl GetSiteRoot.aspx
    This resource directive takes a URL relative to the URL from where the user script is installed from and downloads the response alongside user script itself.

    This allows me to call
    GM_getResourceText('rootUrl')
    in the body of the user script and know exactly where my script was installed from w/o having to make any changes from environment to environment.

    P.S. I will, however, submit a feature request for this to be added GM_Info API.

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

Sidebar

Related Questions

I have a local build of my site running at local.mydomain.com. I'm making ajax
We have a few different websites running on the same server that all access
I have setup a test enviorment on server and there are few websites running
I have a site running on amazon elastic beanstalk with the following traffic pattern:
I have a site running on Magento and i have build some hand made
I have a site running in django and want to make it available on
I have a mobile site running with jQuery Mobile. I want to have standard
I have my site up and running but experiencing rendering issues in MS IE8
I have a Joomla (nginx + mysql) site running as UI and some JSP
I have a asp:Wizard control on a site running Framework 3.5. I acquired the

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.