@@ -64,6 +64,7 @@ import 'package:torn_pda/torn-pda-native/auth/native_user_provider.dart';
64
64
import 'package:torn_pda/utils/html_parser.dart' as pda_parser;
65
65
import 'package:torn_pda/utils/js_snippets.dart' ;
66
66
import 'package:torn_pda/utils/shared_prefs.dart' ;
67
+ import 'package:torn_pda/utils/webview/webview_utils.dart' ;
67
68
import 'package:torn_pda/widgets/bounties/bounties_widget.dart' ;
68
69
import 'package:torn_pda/widgets/chaining/chain_widget.dart' ;
69
70
import 'package:torn_pda/widgets/city/city_widget.dart' ;
@@ -2838,7 +2839,9 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
2838
2839
_cityTriggered = false ;
2839
2840
_profileTriggered = false ;
2840
2841
_attackTriggered = false ;
2841
- } else if (_currentUrl.contains ("torn.com/profiles.php?XID=" ) && _profileTriggered) {
2842
+ } else if ((_currentUrl.contains ("torn.com/profiles.php?XID=" ) ||
2843
+ _currentUrl.contains ("torn.com/profiles.php?NID=" )) &&
2844
+ _profileTriggered) {
2842
2845
_crimesTriggered = false ;
2843
2846
_gymTriggered = false ;
2844
2847
_vaultTriggered = false ;
@@ -4007,7 +4010,7 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
4007
4010
}
4008
4011
4009
4012
// ASSESS PROFILES
4010
- Future _assessProfileAttack ({dom.Document ? document, String pageTitle = "" }) async {
4013
+ Future _assessProfileAttack ({required dom.Document document, String pageTitle = "" }) async {
4011
4014
if (mounted) {
4012
4015
if (! _currentUrl.contains ('loader.php?sid=attack&user2ID=' ) &&
4013
4016
! _currentUrl.contains ('loader2.php?sid=getInAttack&user2ID=' ) &&
@@ -4046,29 +4049,34 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
4046
4049
// When the URL is constructed with name instead of ID (e.g.: when the heart icon is pressed),
4047
4050
// we capture the ID from the profile element, ensuring that it's besides the correct name
4048
4051
4049
- final RegExp regId = RegExp (r"php\?NID=([^&]+)" );
4050
- final matches = regId.allMatches (_currentUrl);
4051
- final String username = matches.elementAt (0 ).group (1 )! ;
4052
+ final result = await WebViewUtils .waitForElement (
4053
+ webViewController: webViewController! ,
4054
+ selector: 'a.profile-image-wrapper[href*="XID="]' ,
4055
+ maxSeconds: 6 ,
4056
+ intervalSeconds: 1 ,
4057
+ returnElements: true ,
4058
+ );
4052
4059
4053
- final dom. Element userInfoValue = document ! . querySelector ( 'div.user-info-value' ) ! ;
4054
- final String textContent = userInfoValue. querySelector ( 'span.bold' ) ! .text. trim ();
4055
- final RegExp regUsername = RegExp ( '($ username ' r')\s*\[([0-9]+)\]' ) ;
4056
- final match = regUsername. firstMatch (textContent) ;
4057
- if (match != null ) {
4058
- setState (() {
4059
- _profileAttackWidget = ProfileAttackCheckWidget (
4060
- key : UniqueKey (),
4061
- profileId : int . parse (match. group ( 2 ) ! ),
4062
- apiKey : _userProvider ? .basic ? .userApiKey ?? "" ,
4063
- profileCheckType : ProfileCheckType .profile ,
4064
- themeProvider : _themeProvider ,
4065
- );
4066
- });
4067
- }
4068
- } else {
4069
- userId = 0 ;
4060
+ if (result == null ) throw ( "No html tag found" ) ;
4061
+
4062
+ document = result[ 'document' ] as dom. Document ;
4063
+ final elements = result[ 'elements' ] as List <dom. Element > ;
4064
+ final anchor = elements.first;
4065
+ final match = RegExp ( r"XID=([^&]+)" ). firstMatch (anchor.attributes[ 'href' ] ! ) ! ;
4066
+ userId = int . parse (match. group ( 1 ) ! );
4067
+
4068
+ setState (() {
4069
+ _profileAttackWidget = ProfileAttackCheckWidget (
4070
+ key : UniqueKey () ,
4071
+ profileId : userId ,
4072
+ apiKey : _userProvider ? .basic ? .userApiKey ?? "" ,
4073
+ profileCheckType : ProfileCheckType .profile,
4074
+ themeProvider : _themeProvider,
4075
+ );
4076
+ }) ;
4070
4077
}
4071
- } catch (e) {
4078
+ } catch (e, trace) {
4079
+ log ("Issue locating NID user ID: $e , $trace " , name: "Profile Check" );
4072
4080
userId = 0 ;
4073
4081
}
4074
4082
} else if (_currentUrl.contains ('loader.php?sid=attack&user2ID=' ) ||
0 commit comments