C
C
Cyril2017-05-04 14:43:12
Google Chrome
Cyril, 2017-05-04 14:43:12

How to interact with the DOM tree through a chrome extension?

Good afternoon. I am writing my first extension for chrome, I need it for work:
The extension has: a text field and a button, when you click on the button, a search should occur for what the user wrote in the text field on the page (similar to ctrl + f). But, I am writing this so that the search is needed on the large menu aka the accardion menu, which is hidden (collapsed) by default, so until you expand it, the search is not possible.
The task of the plugin is to expand this tree and find in it what is written in the text field.
Created files:
index.html - plugin body
jquery.js - jquery library is connected lol
manifest.json - manifest file itself
popup.js - jq script itself that should change DOM
The site itself is not available to me, all operations are on the client side, that's why I write the plugin
In manifest.json I have this:

{
    "manifest_version": 2,
 
    "name": "ИМЯ ПЛАГИНА",
    "description": "Можно модули поискать. Удобно.Наверное...",
    "version": "1.0",
 
    "browser_action": {
      "run_at": "document_start",
      "css": ["css.css"],
      "matches": ["урл.сайта"],
        "default_icon": "icon.png",
        "default_popup": "index.html",
      "js": ["jquery.js", "popup.js"]
    }
 }

Firebag went through that site, found the style responsible for collapsing / expanding the menu:
.ng-hide {
display:none !important
}

accordingly, it is necessary that these classes be visible
In popup.js, I did it like this: (with anticipation that nothing will come of it)
$('ng-hide').css({'display:block !important'});
and nothing happened, there is no interaction with the DOM.
So guys, please, tell me how I can force the browser to change DOM tree objects through the plugin

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-05-04
@alexey-m-ukolov

https://developer.chrome.com/extensions/content_scripts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question