violentmonkey: [BUG] 2.21.0 breaks all scripts on Kiwi Browser 124.0.6327.4
Sequence of actions:
- Install NGA Redirector https://greasyfork.org/en/scripts/413385-nga-redirector (a simple example script)
- Open nga.178.com
- Violentmonkey shows an error:
The script didn’t exist or didn’t match the URL when the page loaded, which happens in Single-Page Application sites like fb or instagram that are using fake navigation. You can reload the tab to run the script. To fix the script use @match for the entire site and then detect changes using MutationObserver or window.navigation API.
Problem:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'inject')
at GetInjected (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/background/index.js:1:184311)
at async Lc (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/background/index.js:1:190682)
at async u (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/background/index.js:1:1710) Error: callstack before invoking sendMessage:
at Proxy.<anonymous> (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:2232)
at je (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:3326)
at Ne (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:3438)
at je (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:3309)
at nt (chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:4595)
at chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:14212
at chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:14542
at chrome-extension://jinjaccalgkegednnccohejagnlnfdag/injected.js:1:15295
Expected result:
It should redirect to bbs.nga.cn
Devtools console contents:
Same as “Problem”
Environment:
- OS: Android
- Browser: Kiwi Browser 124.0.6327.4
- Violentmonkey Version: 2.21.0
This script is work fine with 2.20.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 12
- Comments: 26 (12 by maintainers)
I’ve tweaked the fix a little, please re-test it: Violentmonkey-test-webext-v2.21.0-4-gdcf7448.zip
It was a mistake in our code that was exposed by Kiwi, but theoretically it could have happened in any other browser. It’s fixed now.
Make a new stable release then, I guess.
@gera2ld looks like it is working
Right… let me dig a little more. It’s really hard to debug since the devtools doesn’t show anything for background.
Download Violentmonkey-webext-v2.20.0.zip from https://github.com/violentmonkey/violentmonkey/releases/tag/v2.20.0 , and install it in extensions page -> from zip/crx
It works for me.
@akiirui @Thorvarium could you help to verify this package? Thanks. dist.zip
Yeah, but how this is possible when bagNoOp has
injectexplicitly defined?Updated.
There are 2 issues.
env[PROMISE]is set to null when it shouldn’t.https://github.com/violentmonkey/violentmonkey/blob/66922d6f2b9b9d75eed7fa52715bce81a07bcb57/src/background/utils/preinject.js#L388-L398
env[PROMISE]is set for the first time (Promise 1)env[PROMISE]is overridden (Promise 2) but the original promise will be awaited at Line 397env[PROMISE]will be set to null so that Promise 2 will not be awaited by the subsequent code:https://github.com/violentmonkey/violentmonkey/blob/66922d6f2b9b9d75eed7fa52715bce81a07bcb57/src/background/utils/db.js#L408
browser.windows.get(id)throws an error saying that the window does not exist.https://github.com/violentmonkey/violentmonkey/blob/66922d6f2b9b9d75eed7fa52715bce81a07bcb57/src/background/utils/preinject.js#L679
Warning : scripts have to be reinstalled when doing this.
Having the same thing happen, violent monkey not working on kiwi