M
M
masimka2018-06-25 12:14:12
Google Chrome
masimka, 2018-06-25 12:14:12

How to remove caching google extension (content_script)?

Downloaded the extension in developer mode, unpacked. The extension parses page content and uploads it to local storage for further processing. Everything works correctly, except for one thing, it does not run every time I visit a particular page.
I noticed that content_script (cntn.js) works once or even twice.
Manifesto

{
    "manifest_version": 2,
 
    "name": "import",
    "description": "This extension will import ",
    "version": "dfasdas",

    "browser_action": {
        "default_icon": "32x32.png",
        "default_popup": "popup.html"
    },
    "content_scripts": [
        {
          "matches": ["https://site/p3/xcxc/fgfg/*/print"],
          "js": ["cntn.js"],
          "all_frames" : false,
          "run_at" : "document_end"
        }
      ],

      "background": {
        "scripts": ["background.js"]
      },

    "permissions": [
        "activeTab", "storage", "http://localhost:8080/#/", "management", "tabs"
    ]
}

How to make a script (cntn.js) run every time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
masimka, 2018-06-26
@masimka

I can answer this question:
very simply, the content of the script is obtained, the content is parsed after completion of DOMContentLoaded (

window.onload = function() {,
document.addEventListener("DOMContentLoaded",,
document.addEventListener("load", function() ,

) and sends the message to background.js
THAT puts it in storage for further processing.
The question was that this is not a cache, but the page receives content without reloading the page.
Therefore, you need to apply content oserve and look at the change in child objects.
And for this you need to start an event to eavesdrop onHistoryStateUpdated then it will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question