VB6: AddWebResourceRequestedFilter and ico, svg not blocked - Printable Version +- Antwise community forums (https://forums.antwise.com) +-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11) +--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12) +--- Thread: VB6: AddWebResourceRequestedFilter and ico, svg not blocked (/showthread.php?tid=160) |
VB6: AddWebResourceRequestedFilter and ico, svg not blocked - MrPrzemek - 2023-08-08 Hi. I started using the AddWebResourceRequestedFilter method on v1.1.270 build OCX. It seems to be super for my needs. However, I noticed that when it blocks rcImage and rcMedia it still downloads graphics in ICO and SVG format. I use code like this: antView.AddWebResourceRequestedFilter "*", rcImage antView .AddWebResourceRequestedFilter "*", rcMedia Private Sub antView_OnWebResourceRequested(ByVal Args As AntViewAx.IAntViewWebResourceRequestedEventArgs) Dim NewResponse As AntViewWebResourceResponse If Args.ResourceContext = rcImage Then Set NewResponse = wbEdge.CreateWebResourceResponse("", 403, "Blocked", "") Args.Response = NewResponse Exit Sub End If If Args.ResourceContext = rcMedia Then Set NewResponse = wbEdge.CreateWebResourceResponse("", 403, "Blocked", "") Args.Response = NewResponse End If End Sub Results preview code Private Sub AntView_OnWebResourceResponseReceived(ByVal Request As AntViewAx.IAntViewWebResourceRequest, ByVal Response As AntViewAx.IAntViewWebResourceResponseView) If Response.StatusCode <> 403 Then Debug.Print Response.StatusCode & " - " & Request.URI 'Status: 200 - https://www.interia.pl/favicon.svg 'Status: 200 - https://www.interia.pl/favicon.ico End If End Sub Am I doing something wrong or maybe favicon can't be blocked through rcImage/rcMedia? Best regards Przemek RE: VB6: AddWebResourceRequestedFilter and ico, svg not blocked - wila - 2023-08-08 Hi Przemek, Looks like Microsoft determined those are not image or media files. In order to figure that out I adjusted your code a bit like so: Code: Private Sub EdgeWebBrowser_OnWebResourceRequested(ByVal Args As AntViewAx.IAntViewWebResourceRequestedEventArgs) So basically I'm using the first debug.print to find out what the resourceContext is that Microsoft assigned for the file type. This tells me that an svg file is declared as rcOther as is a favicon.ico. You can see this as it reports the following in the output window: Code: https://www.antwise.com/ - 1 If you look at up here: https://doc.antview.dev/hs335.htm then you'll notice that 16 = rcOther. Same thing if you go to your website and look for the .svg file in the debug output. Also note that you can't seem to block images if they are streamed as imagedata. -- Wil RE: VB6: AddWebResourceRequestedFilter and ico, svg not blocked - MrPrzemek - 2023-08-11 (2023-08-08, 13:45:13)wila Wrote: Also note that you can't seem to block images if they are streamed as imagedata. Hi Wil. Thank you for providing accurate information. As usual, the level of help from your side is great :-) By the way do you know how many domains can be added for filtering? I could not find such information on Microsoft's website. I would like to implement a function to block ads and trackers. The example list of tracking server domains contains about 4 thousand items. How do you think adding so many items will not affect the performance of the ActiveX? Best regards Przemek RE: VB6: AddWebResourceRequestedFilter and ico, svg not blocked - wila - 2023-08-11 Przemek, Sorry I don't know if there are any limits and how it would impact performance. For the ActiveX part there is no difference if you filter on one or on 4000 domains. For the underlying WebView2 control things might be different. It shouldn't be an issue to filter for 4000 domains from my point of view. I guess it depends on how it has been implemented underneath. FWIW I haven't seen any complaints about bad performance in this area at their github feedback site. I suppose it is going to be a matter of try & see how it behaves. -- Wil RE: VB6: AddWebResourceRequestedFilter and ico, svg not blocked - MrPrzemek - 2023-08-11 (2023-08-11, 09:50:20)wila Wrote: I suppose it is going to be a matter of try & see how it behaves. Hi. I'm just testing domain filtering with over 2k items and I don't see any problems :-) Thanks for providing the answers Regards Przemek |