M
M
Millerish2017-12-14 12:05:59
JavaScript
Millerish, 2017-12-14 12:05:59

Chrome extension: how to change cookies?

Hey!
I need to somehow change the cookies for the site so that the server receives not the cookies that were, but those that I want.
As far as I understand, this should be done in background.js

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

var d = new Date();
    var n = d.toString();
    chrome.cookies.set({
        "name": "test",
        "url": "https://account.chatoptimizer.com/",
        "value": n
    }, function (cookie) {});

And this option works, but it only works when I update the extension, not the page. How to call the code from background.js while the page is loading (as I understand it, you need to do this before sending the headers)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Arkh, 2017-12-14
@AlekseyArh

Try putting in "content_scripts"

"content_scripts": [
    {
      "matches": [
        "*://site.ru/*"
      ],
      "js": [
        "js/jquery.min.js",
        "js/script.js"
      ]
    }
  ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question