N
N
Nadim Zakirov2022-04-03 15:19:04
JavaScript
Nadim Zakirov, 2022-04-03 15:19:04

How to execute remote code on Manifest V3?

I'm studying Manifest V3 and unfortunately the possibilities have been greatly reduced there.
Is there a way to insert and execute a script on the target site inline ?

INLINE!!! This is the key point.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Надим Закиров, 2022-04-08
@zkrvndm

Решение найдено. Выполнить удаленный код на Manifest V3 можно следующим образом:
1. В манифесте расширения прописываем контент-скрипт для нужного вам сайта.
2. В файле контент-скрипта выполняем вставку тега script со ссылкой src на локальный файл из папки расширения. Это важный момент, на этом этапе нельзя сразу вставить удаленный код, так как расширение просто не даст это сделать ссылаясь на Content Security Policy. Поэтому сначала вставляем скрипт загрузчик, который должен обязательно присутствовать локально внутри с папкой расширения. Не забываем, что для загрузки локального скрипта у вас должны стоят правильные разрешения в манифесте в параметре web_accessible_resources .
3. Already inside this local loader script, which we inserted in step 2, you can download the remote code from your server and insert it inline into the page. It will be guaranteed to be executed in the context of the page as if it were the site's native script. For some, it does not matter in what context we execute the code, but for me it is important, because sometimes in order to generate the correct Event, you need to do it from the context of the page.

A
Alexander, 2022-04-03
@anudas

> paste and execute the script on the target site
, this is how most extensions work and will continue to work.
js runs in the browser on a given site or on given pages and can do everything that front-end js code does. but he can't do what needs to be done on the back

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question