The example module injection works, but the example patch doesn't work. Here is what I did to make it work:
- Twitter changed their domain so
matchSites: ["twitter.com"] becomes matchSites: ["x.com"]
- Twitter breaks with
patchAll: true so I changed it to patchAll: false
- The module with the string
"(window.__INITIAL_STATE__" is successfully found, but then the string replacement fails because /(const|var) .{1,3}=.\..\(window\.__INITIAL_STATE__/ is no longer present in the code. I changed it to { match: /;var .{1,20}\..\(window\.__INITIAL_STATE__/, replacement: (orig) => `;console.log('Patches work!!!')${orig}` } and that worked.
- I had to add unsafe-eval under script-src in the content-security-policy header.