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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:32:33+00:00 2026-06-11T20:32:33+00:00

Good day everyone! I decided to try making an extension for Chrome for the

  • 0

Good day everyone! I decided to try making an extension for Chrome for the first time and I have this idea but I don’t know how to start. I hope you’d point me to the right direction.

I want to detect if a certain URL is opened then change the value of one of its query strings. For example:

  1. I open the page http://downloadpage.url/?page=info&id=123456
  2. The extension will detect this and change the query string “page” value from “info” to “download” and continue opening the page with the new values.

How do I do this? I think the permissions needed would be WebRequest and WebRequestBlocking but I’m not sure. I tried the steps here: Detect if URL is opened – Chrome extension but it doesn’t seem to work even after changing background_page to background to account for my manifest’s version (my Chrome version is 21.0.1180.89). I was hoping I could just modify the code there but unfortunately it didn’t work for me and now I’m lost.

  • 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-11T20:32:34+00:00Added an answer on June 11, 2026 at 8:32 pm

    Following Rob W’s link in his comment above (Thanks Rob!) I came up with some code that works according to what I wanted. First I added the following to the manifest to run a content script when I’m in the intended URL:

      "content_scripts": [
         {
           "matches": [
              "http://downloadpage.url/*"
           ],
           "js": ["background.js"]
         }
      ]
    

    Obviously the URL is fake…

    Then created a file called background.js with the following function which makes it easy to grab the query strings. The original code came from here and I modified it a bit to make it reusable for other links or strings.:

    function getQueryString(URL) {
      if (!URL) {
        URL = location.search;
      }
      else
      {
        var a = document.createElement('a');
        a.href = URL;
        URL = a.search;
      }
    
      var result = {}, queryString = URL.substring(1),
          re = /([^&=]+)=([^&]*)/g, m;
    
      while (m = re.exec(queryString)) {
        result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
      }
    
      return result;
    }
    

    Then finally the code that does the redirect with the modified query string is below:

    if (page == "info")
    {
      var ID = getQueryString()["id"];
    
      location.replace('http://downloadpage.url/?page=download&id='+ID;);
    }
    

    I’m still open for better and more elegant solutions but this does what I want to do. If you have a better idea please let me know. Cheers!

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

Sidebar

Related Questions

Good day everyone. I have a question about making and using derived classes of
Good day everyone. I have an audio class, that plays a .wav file. But
Good day everyone, I'm new in C programming and I don't have a lot
Good day everyone. I am working on a Firefox extension, and I want to
Good day everyone. I have been having the same problem all day at work
Good day everyone! I have a problem regarding my date. It needs to be
Good day everyone, this is one of those areas that is a little over
Good day everyone I need to execute command on linux machine this command is
Good day everyone, I have the following XML data : <?xml version=1.0 encoding=utf-8 ?>
Good day everyone. Suppose we have a collection and a document which looks something

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.