Skip to content

Example patch doesn't work #2

@bingbangbopper

Description

@bingbangbopper

The example module injection works, but the example patch doesn't work. Here is what I did to make it work:

  1. Twitter changed their domain so matchSites: ["twitter.com"] becomes matchSites: ["x.com"]
  2. Twitter breaks with patchAll: true so I changed it to patchAll: false
  3. 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.
  4. I had to add unsafe-eval under script-src in the content-security-policy header.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions