Skip to content

Commit

Permalink
detect if running as browser extension
Browse files Browse the repository at this point in the history
  • Loading branch information
peerchemist committed Dec 12, 2024
1 parent e62e7d6 commit cd81732
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import 'tools/app_localizations.dart';
import 'tools/app_routes.dart';
import 'tools/app_themes.dart';
import 'tools/session_checker.dart';
import 'tools/browser_extension_detector.dart';
import 'widgets/spinning_peercoin_icon.dart';

late bool setupFinished;
Expand Down Expand Up @@ -178,6 +179,10 @@ void main() async {
);
}

if (kIsWeb && getChromeRuntimeId() != null) {
// TODO: do something with this revelation
}

//run
runApp(const PeercoinApp());
}
Expand Down
13 changes: 13 additions & 0 deletions lib/tools/browser_extension_detector.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dart:js_interop';

@JS('chrome.runtime.id')
external JSString? get chromeRuntimeId;

String? getChromeRuntimeId() {
try {
final id = chromeRuntimeId;
return id?.toDart;
} catch (e) {
return null;
}
}

0 comments on commit cd81732

Please sign in to comment.