From 3d182de9840b6de3c4be1b309641f1223b95e088 Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Tue, 17 Oct 2023 21:06:10 +0200 Subject: [PATCH] [race hub] replace the webview with an accout-free alternative --- lib/Screens/session_screen.dart | 54 +++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/Screens/session_screen.dart b/lib/Screens/session_screen.dart index 3408ba80..0b848040 100644 --- a/lib/Screens/session_screen.dart +++ b/lib/Screens/session_screen.dart @@ -46,6 +46,50 @@ class SessionScreen extends StatefulWidget { } class _SessionScreenState extends State { + final List adUrlFilters = [ + ".*.pubtm.com/.*", + ".*.pubperf.com/.*", + ".*.uniconsent.com/.*", + ".*.advertserve.com/.*", + ".*.zqtk.net/.*", + ]; + final List contentBlockers = []; + + @override + void initState() { + super.initState(); + if (!kIsWeb) { + for (final adUrlFilter in adUrlFilters) { + contentBlockers.add( + ContentBlocker( + trigger: ContentBlockerTrigger( + urlFilter: adUrlFilter, + ), + action: ContentBlockerAction( + type: ContentBlockerActionType.BLOCK, + ), + ), + ); + List selectors = [ + ".bs-sticky", + ".bs-block", + ".unic", + ]; + contentBlockers.add( + ContentBlocker( + trigger: ContentBlockerTrigger( + urlFilter: ".*", + ), + action: ContentBlockerAction( + type: ContentBlockerActionType.CSS_DISPLAY_NONE, + selector: selectors.join(', '), + ), + ), + ); + } + } + } + @override Widget build(BuildContext context) { bool useDarkMode = @@ -143,9 +187,12 @@ class _SessionScreenState extends State { body: InAppWebView( initialUrlRequest: URLRequest( url: WebUri( - "https://www.formula1.com/en/live-experience-webview.html", + "https://live.planetf1.com/", ), ), + initialSettings: InAppWebViewSettings( + contentBlockers: contentBlockers, + ), gestureRecognizers: { Factory( () => VerticalDragGestureRecognizer(), @@ -265,9 +312,12 @@ class _SessionScreenState extends State { : InAppWebView( initialUrlRequest: URLRequest( url: WebUri( - "https://www.formula1.com/en/live-experience-webview.html", + "https://live.planetf1.com/", ), ), + initialSettings: InAppWebViewSettings( + contentBlockers: contentBlockers, + ), gestureRecognizers: { Factory( () => VerticalDragGestureRecognizer(),