Using the Chrome extension to change the Google search results page

I want the Chrome extension to change the Google search results page. I know that I can use the script content to do this because it has the ability to do this. But, unfortunately, this fails. I wrote the code

$('h3.r').append('<b>a</b>')

or something else related to DOM operations, they all failed. But if I just wrote

alert('aa')

or

document.body.style.backgroundColor='green'

it works. What for? By the way, I want to have debugging, but when I open the development tools, I can not find my content extension script. I see content scripts for other extensions.

+5
source share
2 answers

Have you added jQuery to your content_scripts in the manifest?

jQuery, manifest.json :

 "content_scripts":[
        {
            "matches":["http://www.google.com/*"],
            "js":["jquery-1.9.1.min.js", "contentscripts.js"]
        }
]

, google. , , :

Google AJAX, , , , - DOM .

, DOMNodeInserted.

:

function fundH3(){
  $('h3.r').append('<b>a</b>')

}

searchResultArea.addEventListener('DOMNodeInserted', findH3);
+3

URL (S),

{
 ---
    "permissions": [
        "https: //www.google.co.in/*"
    ]
 ---
}

0

All Articles