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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:52:48+00:00 2026-06-06T08:52:48+00:00

I am writing a Greasemonkey userscript, for a site which has two domains. Let’s

  • 0

I am writing a Greasemonkey userscript, for a site which has two domains. Let’s say http://friendlyurl.com and http://ugly.url.com. http://friendlyurl.com/* redirects to http://ugly.url.com/*.
One of the features I wanted to include in the userscript was rewriting the ugly URL to the friendly one using HTML5 replaceState().

The code I had was:

(function() {
    if (history.replaceState) {
        var url = document.location.href.replace('ugly.url.com/', 'friendlyurl.com/');
        history.replaceState({}, document.title, url);
    }
})();

Until I realized this disobeys the Same-Origin policy. My question is: is there a workaround to switch the site’s domain, potentially using the GM_* API? Obviously as this is a userscript the security issue is on a much lower scale.
My current guess is that it is not possible, but I thought I’d put the question out there.

  • 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-06T08:52:50+00:00Added an answer on June 6, 2026 at 8:52 am

    history.replaceState cannnot be used to change the domain, for security reasons. Not even through a GM API.

    See more details on the rules in the HTML Standard for replaceState().

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

Sidebar

Related Questions

I'm writing a UserScript (=Greasemonkey) which I am developing in FireFox but works in
I am writing a Greasemonkey script in which in one place I'm converting all
I am writing a greasemonkey script. The site is using jquery, i need a
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I'm writing some javascript (a greasemonkey/userscript) that will insert some input fields into a
I'm writing a greasemonkey script that creates an auto-complete search type box which makes
So, I'm writing a little Greasemonkey Userscript and its working fine in Firefox however
I'm writing a GreaseMonkey script, as part of which I'd like to sort a
I am writing a Chrome Userscript (Greasemonkey) extension to display a confirmation dialog when
I'm writing a Greasemonkey script that has a fair few user settings (just using

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.