1

In tampermonkey, advanced settings, you can find a setting called "Inject mode" at the "Expirimental" tab. Here, you can select a mode called "Instant".

I was wondering, what does it do different? How does it work? Is it simular to ViolentMonkeys injection methods?

Nightfall
  • 107
  • 1
  • 10

1 Answers1

2

Judging by the source code in other extensions like Stylus or Violentmonkey (beta) that recently added the same feature:

  1. The background script makes a Blob in the background script with the data, gets its URL via URL.createObjectURL, puts it into a Set-Cookie header via chrome.webRequest API.
  2. The content script reads the URL from document.cookie and uses it in a synchronous XMLHttpRequest to get the original data synchronously.

This trick is based on an answer by Xan.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136
  • For reference, the source code of ViolentMonkey's implementation is available here: https://github.com/violentmonkey/violentmonkey/pull/1100 – 比尔盖子 Mar 30 '23 at 00:56