Skip to content

Commit

Permalink
[race hub] replace the webview with an accout-free alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Oct 17, 2023
1 parent f106af6 commit 3d182de
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions lib/Screens/session_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,50 @@ class SessionScreen extends StatefulWidget {
}

class _SessionScreenState extends State<SessionScreen> {
final List adUrlFilters = [
".*.pubtm.com/.*",
".*.pubperf.com/.*",
".*.uniconsent.com/.*",
".*.advertserve.com/.*",
".*.zqtk.net/.*",
];
final List<ContentBlocker> 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<String> 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 =
Expand Down Expand Up @@ -143,9 +187,12 @@ class _SessionScreenState extends State<SessionScreen> {
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>(
() => VerticalDragGestureRecognizer(),
Expand Down Expand Up @@ -265,9 +312,12 @@ class _SessionScreenState extends State<SessionScreen> {
: 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>(
() => VerticalDragGestureRecognizer(),
Expand Down

0 comments on commit 3d182de

Please sign in to comment.