A
A
Alexey Esin2021-05-15 15:22:05
JavaScript
Alexey Esin, 2021-05-15 15:22:05

How to change header via chrome extensions?

Hello, there is a working program open in one tab. In the working program there is a button "login to the switch", when pressed, a new tab opens where authorization is required. Authorization is the simplest "login:password". When you press the button, you need to change the authorization token, generate the desired login and pass, and only after that send a request so that the web face of the switch opens immediately without entering a login and password. How can this be done? Using an extension to embed custom code in a page? Or intercept the click in the extension and use it to open a new tab with its own header? And how do you form a header for a request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OVK2015, 2021-05-15
@royal-gaben

Read about localstorage. Store the authorization token in it. When opening a site, the extension looks to see if there is a token in localstorage. If there is, it "reopens" the page by sending a fetch request to the server with this token. Yes, that's all. And how the header with this token will look like depends on the implementation of authorization on the server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question