R
R
razoranti2015-10-11 09:22:17
JavaScript
razoranti, 2015-10-11 09:22:17

How can I interact with the page using the script from the add-on? content script? Or another way?

Needed: Make a Chrome extension that will append to the current tab's style. What kind of script do I need? content script? What should be written in manifest.json? Can he do it? It's not entirely clear in the add-on guides. If someone has an example, I would be glad to see ... I tried to inject the script in various ways, but either it could not be done, or it was injected before the page was loaded and onload somehow did not even save, or it did not have access to the page , or it runs in isolation, is unclear. The script should run on button click. I do not want to share the code, I still want to rewrite it myself. Just need an example or advice.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Malinochkin, 2015-10-18
@DiAsCrafts

To inject scripts, you need to use content_scripts . An example of a solution to your problem on Gist .
13985c29320747bd907a3a6bf8fcde6e.png

R
razoranti, 2015-10-12
@razoranti

{
  "manifest_version": 2,

  "name": "Readable Now",
  "description": "Changes font style for the desired page. No more Times New Roman 8 px!",
  "version": "0.1",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html",
    "default_title": "Options"
  },
  "permissions": [
    "activeTab",
    "http://*/"
  ],
  "background": {
    "scripts": ["background.js"]
  },
  "web_accessible_resources": [
    "/injected.js"
  ]
}

In injected - what needs to be executed. background is not sure if it is needed at all, or what needs to be written in it in order to inject the script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question