mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
Fix autocmddelete cannot remove webrequest event handler
Original code will overwrite the whole object if the same event is regist even in different url pattern. E.g: ``` autocmd BeforeRequest https://*/*?handler1 e=>({cancel:true}) autocmd BeforeRequest https://*/*?handler2 e=>({cancel:true}) " this will throw an error autocmddelete BeforeRequest https://*/*?handler1 ```
This commit is contained in:
parent
79019b65fd
commit
eed0f18f31
1 changed files with 2 additions and 1 deletions
|
@ -22,7 +22,8 @@ export const registerWebRequestAutocmd = (
|
|||
// I'm being lazy - strictly the functions map strings to void | blocking responses
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const listener = eval(func) as Function
|
||||
LISTENERS[requestEvent] = { [pattern]: listener }
|
||||
if (!LISTENERS[requestEvent]) LISTENERS[requestEvent] = {}
|
||||
LISTENERS[requestEvent][pattern] = listener
|
||||
return browser.webRequest["on" + requestEvent].addListener(
|
||||
listener,
|
||||
{ urls: [pattern] },
|
||||
|
|
Loading…
Add table
Reference in a new issue