0

I am writing a User Script and now need to implement the following in pure javascript:

  1. Redirect/open with a new page/jump to a new URL
  2. At the same time, the request uses a customized user agent

How can I achieve this?

Details:

For example, the script runs in https://wenku.baidu.com/view/b249cb95ff4733687e21af45b307e87100f6f861.html

And then I need to use the script to jump to https://wk.baidu.com/view/b249cb95ff4733687e21af45b307e87100f6f861.html

The reason why I have to change the user agent is that its server will detect the UA and return the according url (the same to the old).

Allen Lv
  • 31
  • 3
  • You can't do that with JS. Althought changing the user agent with JS is possible, an unchanged agent is send to a server, even when you can retrieve a changed agent with JS. To send a fake agent, you've to use DevTools. – Teemu Dec 13 '21 at 09:27
  • Thanks for your telling. But I can't ask users to install another agent switcher extension, so if there is any way to solve my problem within a user script? – Allen Lv Dec 13 '21 at 09:39
  • Yes, thanks. In conclusion, there's no way using a user script but only the way using an extension. – Allen Lv Dec 13 '21 at 15:19

0 Answers0