-
Notifications
You must be signed in to change notification settings - Fork 3k
Script Injection in Firefox
Garvan Keeley edited this page Mar 19, 2020
·
2 revisions
Injected JS is compacted into single scripts using webpack. There are 4 autogenerated webpacked js files.
Note:
- The scripts to insert should also be added to the project but not added to any target.
- The actual injected scripts are in Client/Assets folder. These are autogenerated.
- All scripts get the security token injected. The autogenerated webpack scripts are wrapped in an IIFE that injects this token when swift loads them for injection.
Steps:
-
Add the script you would like to inject in the proper folder
- /Client/Frontend/UserContent/UserScripts/
- AllFrames/
- AtDocumentEnd/
- AtDocumentStart/
- MainFrame/
- AtDocumentEnd/
- AtDocumentStart
- AllFrames/
The AllFrames, MainFrame folder tells the frame where the script gets inserted
The location of the script is determined by the folder AtDocumentEnd, AtDocumentStart which tells webpack where the js script will be inserted
- /Client/Frontend/UserContent/UserScripts/
-
Also, add the script to the app but not to the target under the proper folder as described in step 1.
-
UserScriptManager.swift injects js script in the form of
WKUserScript
into theWKWebView
. This file shouldn't need modification. -
Once you have successfully inserted script
- run
./bootstrap.js
- The folder should get updated with new compact scripts
- Client/Assets/
- Commit the changes to your branch
- run
Important Files:
- bootstrap.sh → package.json → webpack.config.js → UserScriptManager.swift