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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:04:43+00:00 2026-05-29T09:04:43+00:00

I am looking to create an extension for a particular site to provide additional

  • 0

I am looking to create an extension for a particular site to provide additional formatting and sharing options that they don’t currently have.

I am having issues getting things to communicate properly and there doesn’t seem to be a clearly laid out example.

Manifest:

{
    "name": "Test",
    "description": "Testing.",
    "version": "1.0",
    "background_page": "background.html",
    "permissions": [
        "tabs", "http://www.sitedomain.com/*"
    ],
    "content_scripts": [
        {
            "matches": ["*://*.sitedomain.com/*"],
            "js": ["jquery.min.js", "test.js"],
            "css": ["test.css"]
        }
    ]
}

Content Script:

$(document).ready(function () {
    alert('test js fired');
    $("#ColumnContainer div.item").each(function () {
        $(this).css("background-color", "skyBlue");
        var itemId = $(this).children("a.itemImage").attr("href");
        $(this).children(".details").append("<a href=\"javscript:void(false);\"  onclick=\"gotoItem('" + itemId + "');\">Goto Item</a>");

    });
});
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) {
    alert('listener request');
    alert(request);
}); 

JavaScript of Background HTML:

    chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
        if (changeInfo.status == "complete") {
            if (tab.url.indexOf("sitedomain.com") > -1) {

                chrome.tabs.executeScript(null, {file: "test.js"});
            }

        }
    });
    chrome.tabs.sendRequest(tabId, request, responseCallback);
    function responseCallback() {
        alert('response callback');
    }
    function gotoItem(itemId) {
        alert('goto Item - ' + itemId);
    }

The above code does append the link and change the styling on the client page when the sitedomain.com is loaded. However, I haven’t had any luck getting the gotoItem method to fire, Chrome Dev Tools shows undefined. I have tried various combinations, but just can’t quite grasp the listeners and requests yet.

I would really like to see a clean sample that just shows how to call a method from each site.

  • 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-29T09:04:44+00:00Added an answer on May 29, 2026 at 9:04 am

    I see two issues with your code. 1) the gotoItem function is defined in the background page and content_scripts can’t access functions there. 2) content_scripts and javascript on pages they are injected into can not interact so your onclick can’t be part of the links html.

    To fix #1 is as simple as moving the gotoItem function to be in the content_script.

    To fix #2 something like the following should work.

    $("#ColumnContainer div.item").each(function(){
        $(this).css("background-color","skyBlue");
        var itemId = $(this).children("a.itemImage").attr("href");
        var $link = $('<a href="javscript:void(false);">Goto Item</a>');
        $link.click(function() {
          gotoItem(itemId);
        }
        $(this).children(".details").append($link);
    });
    

    You may have to modify how itemId gets passed.

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

Sidebar

Related Questions

I am looking to create Extension classes that extend Entity Framework Entities in a
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create something like in this image. Each block would have an
I am looking to create a reg ex in JS that obtains 2 values
I'm looking to create a command line menu in powershell, with the options coming
I am looking to create something that resembles a table in Tkinter but it
I'm looking to create a windows program that doesn't require any environmental dependencies (like
I was looking at my profiler and it seem that the Linq extension method
I want to create an IE extension - a sidebar (Explorer bar) looking just

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.