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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:09:46+00:00 2026-05-24T14:09:46+00:00

I’m Developing an chrome extension and encountered an problem i cannot solve ;/ I

  • 0

I’m Developing an chrome extension and encountered an problem i cannot solve ;/

I wrote the manifest file and some java script code. Everything is working good except buttons. When I click them they should fire the echo function with an parameter and send it further to a plugin developed in firebreath. When I inject code manually in a html file everything is working fine but when injecting the code through javascript chrome console gives me an message that echo function is not defined. I tried several ways to inject the code but none work.

So I ask for help or some good advice fellow programmists. (First post shy)

Main javascript file chrome_script.js

var Reg = /(\+48\s?[0-9]{3}[\-\ ]?[0-9]{3}[\-\ ]?[0-9]{3})|(\+48\s?[\(\ ]?[0-9]{2}[\)\ ]?[0-9]{2,3}[\-\ ]?[0-9]{2}[\-\ ]?[0-9]{2})/g

var content = document.body.innerHTML;

var phoneNumbers = content.match(Reg);

document.getElementsByTagName('head')[0].innerHTML +='<script src="'+chrome.extension.getURL("plug_fun.js")+'" type="text/javascript"></script>';

content = "<object id=\"plugin0\" type=\"application/x-testplugin\" width=\"100%\" height=\"300\"></object>" + content;

for (var i = 0; i < phoneNumbers.length; i++) {
    content = content.replace(phoneNumbers[i], "<button id=\"" + i + "\" type=\"button\" onclick=\"javascript:echo(" + phoneNumbers[i].replace(new RegExp("[\+\ ]", "g"),"") + ")\">" + phoneNumbers[i] + "</button>");
}

document.body.innerHTML = content;

javascript file plug_fun.js, for plugin and buttons

function plugin0(){
    return document.getElementById('plugin0');
}
plugin = plugin0;  
function echo(a){
    var num = String(a);
    plugin().echo(num);
}

manifest file manifest.json

{
    "name": "Phone Injection",
    "version": "0.2",
    "browser_action": {
        "default_icon": "Phone.ico"
    },
    "permissions": [
            "tabs", "http://*/*", "https://*/*", "file://*"
    ],
    "plugins": [
        { "path": "npTestPlugin.dll", "public": true }
        ],
    "content_scripts": [ {
        "matches": ["http://*/*", "https://*/*", "file://*"], 
        "js": ["chrome_script.js", "plug_fun.js"]
    }]
}

Error caught when clicking the button

Uncaught ReferenceError: echo is not defined

  • 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-24T14:09:47+00:00Added an answer on May 24, 2026 at 2:09 pm

    Content scripts in Chrome Extensions execute in something Google calls “isolated worlds”. This means that the different scripts are not allowed to see or interact with each other and appear as if there is no other JavaScript executing on the page. See below for more info directly from the Google Documentation:

    Content scripts execute in a special environment called an isolated world. They have access to the DOM of the page they are injected into, but not to any JavaScript variables or functions created by the page. It looks to each content script as if there is no other JavaScript executing on the page it is running on. The same is true in reverse: JavaScript running on the page cannot call any functions or access any variables defined by content scripts.
    Quoted from: http://code.google.com/chrome/extensions/content_scripts.html#execution-environment

    I would suggest trying to put the code that will interface with the firebreath plugin in a background script instead, although I would double check and make sure those don’t also execute in isolated environments as well.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is 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.