Try to block GIF content(not URL) but don't know how.
Posted: Tue Feb 18, 2025 5:42 pm
Hello,
I recently ran into a problem where I wanted to block some ads in my app's browser, usually by blocking the URL with a regex or deleting certain elements with js. However, there is a special case where the URL doesn't have a special gif extension or anything like that, and there is no attribute labeled image, but it gets a stream of GIF content and causes the browser to display them.
I've tried many ways, and found that the loading process is only triggered in BeforeResourceLoad and GetResourceHandler events. I was thinking of doing it in GetResourceResponseFilter but it doesn't get triggered.
I have 2 questions.
1. In this case, in which event can I read out the response stream data first, and then replace it with my own if it's a GIF? CustomResponseFilter.OnFilter?
2. Right now the only way I can do this is to match URLs in BeforeResourceLoad, which is not a good way that needs the user to blacklist it for each random URL. Is there a better way to do this?
Thanks for your attention and help!
I recently ran into a problem where I wanted to block some ads in my app's browser, usually by blocking the URL with a regex or deleting certain elements with js. However, there is a special case where the URL doesn't have a special gif extension or anything like that, and there is no attribute labeled image, but it gets a stream of GIF content and causes the browser to display them.
I've tried many ways, and found that the loading process is only triggered in BeforeResourceLoad and GetResourceHandler events. I was thinking of doing it in GetResourceResponseFilter but it doesn't get triggered.
I have 2 questions.
1. In this case, in which event can I read out the response stream data first, and then replace it with my own if it's a GIF? CustomResponseFilter.OnFilter?
2. Right now the only way I can do this is to match URLs in BeforeResourceLoad, which is not a good way that needs the user to blacklist it for each random URL. Is there a better way to do this?
Thanks for your attention and help!