0

I am building a Chrome extension with which I'd like to insert some text between the "link" and the "description" on each Google search result and also write the title of each link to the console. See the screenshot and the code below

screenshot

Manifest.json

{
  "name": "INJECTA",
  "version": "0.0.1",
  "manifest_version": 2,
  "description": "Abcdefgh",
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": ["jquery-3.1.1.min.js","content.js"],
   "run_at": "document_end"
    }
  ]
}

content.js

$(document).ready(function() {
 $("div.srg").find("h3 > a").each(function (index) {
  console.log("Title: " + this.text);
  $(this).append("<br><span style='color: orange'>My new line text</span>");
 });
});

It works but when I make another search query on the same google page, then it doesn’t work. How can I fix it?

  • 1
    [Is there a JavaScript/jQuery DOM change listener?](//stackoverflow.com/a/39508954) – wOxxOm Dec 17 '16 at 22:17
  • 1
    Possible duplicate of [Is there a JavaScript/jQuery DOM change listener?](http://stackoverflow.com/questions/2844565/is-there-a-javascript-jquery-dom-change-listener) – Makyen Dec 17 '16 at 22:35

0 Answers0