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

  • Home
  • SEARCH
  • 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 3953138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:56:19+00:00 2026-05-20T01:56:19+00:00

I am writing a Chrome extension that needs to modify pages in a specific

  • 0

I am writing a Chrome extension that needs to modify pages in a specific domain according to some given parameter, which needs XSS in order to be obtained, so simply using a content script seems impossible. So, I’ve decided to inject the script using tabs.executeScript.

Now I need to know two things: First, how can I pass parameters to the script when using executeScript? I guess I can use messages, but isn’t there a more direct way to pass the parameter while injecting the script?

Second, my script uses jQuery, so I need to include jQuery somehow. It’s silly, but I’m not sure how to do it. So far, I embedded jQuery in the HTML page I was writing (for example background.html).

  • 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-20T01:56:20+00:00Added an answer on May 20, 2026 at 1:56 am

    If you don’t want to use messaging then:

    chrome.tabs.executeScript(tabId, {file: "jquery.js"}, function(){
        chrome.tabs.executeScript(tabId, {code: "var scriptOptions = {param1:'value1',param2:'value2'};"}, function(){
            chrome.tabs.executeScript(tabId, {file: "script.js"}, function(){
                //all injected
            });
        });
    });
    

    (jquery.js should be placed into extension folder). Script options will be available inside scriptOptions variable in the script.js.

    With messaging it is just as easy:

    chrome.tabs.executeScript(tabId, {file: "jquery.js"}, function(){
        chrome.tabs.executeScript(tabId, {file: "script.js"}, function(){
            chrome.tabs.sendMessage(tabId, {scriptOptions: {param1:'value1',param2:'value2'}}, function(){
                //all injected
            });
        });
    });
    

    You would need to add a request listener to script.js:

    chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
        var scriptOptions = message.scriptOptions;
        console.log('param1', scriptOptions.param1);
        console.log('param2', scriptOptions.param2);
        doSomething(scriptOptions.param1, scriptOptions.param2);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Google Chrome extension that needs to do a lot of things
I'm writing a Firefox extension that needs to inject a css file into webpages.
I'm writing a Chrome extension that works with a website that uses ISO-8859-1. Just
I am writing a chrome extension that change part of the url in the
In my case i'm writing a Chrome Extension, I don't have access to the
I am writing a Firefox extension. I have setup an overlay for chrome://browser/content/browser.xul and
I'm writing a Chrome extension, in my background.html page, it is injecting a js
I am writing an extension for the Chrome browser (and later hope to port
I'd like to try my hand at some Chrome Extension Development. The most I
I am trying to get some experience with chrome extensions. I have a question

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.