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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:09:28+00:00 2026-06-04T09:09:28+00:00

I have a small chrome extension which I want to use to change text.

  • 0

I have a small chrome extension which I want to use to change text. It works just the way I want it to(clicking the icon changes text), but on some pages the existing jquery stops working when the app is enabled. What am I doing wrong?

Files: manifest.json, myscript.js and background.html

manifest.json content:

{
  "name": "My extension",
  "version": "1.0",
  "background_page": "background.html",
  "permissions": [
    "tabs", "http://*/*"
  ],
  "content_scripts": [
    {
      "matches": ["http://*/*"],
    "matches": ["https://*/*"],
      "js": ["myscript.js"]
    }
  ],
"browser_action": {
    "default_icon": "icon.png"
    }
}

myscript.js content:

var array = {"not":" NOT ", "like":" LIKE ", "job":"JOBS"}

for (var val in array)
    document.body.innerHTML = document.body.innerHTML.replace(new RegExp(val, "g"),     array[val]);

background.html content:

<script>
chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.executeScript(null,
                       {file:"myscript.js"});
});
</script>
  • 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-04T09:09:29+00:00Added an answer on June 4, 2026 at 9:09 am

    document.body.innerHTML is very bad.

    When you use it, you’re treating DOM nodes as raw text. Those DOM nodes have event handlers and even a simple document.body.innerHTML+='...' will send the existing nodes to oblivion, creating new ones, without event handlers.

    So instead, you need to iterate through all the text nodes in the document (*see here how) and do an innerHTML each one individually.

    Sănătate!

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

Sidebar

Related Questions

I have some text on a page that is small but readable in Chrome/Safari
I have small script in bash, which is generating graphs via gnuplot. Everything works
I have been working on a small Chrome extension with a problem I cant
I'm writing a small Chrome extension that would have a content_script . It would
I have a small problem on IE browser (actually on Google Chrome too) I
I have this small testcase: http://jsfiddle.net/sV8js/ You can see that in Chrome (tested on
I use Google Chrome. I need to have a very tiny HTML editor and
I'm trying to display a small text (new messages count) over icon in toolbar
I have a basic css only dropdown menu that works great in Chrome and
I have the following CSS code, works fine with Firefox, Chrome but breaks like

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.