Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dyang886 committed Jan 21, 2025
1 parent eb5e52b commit 57c8447
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/scripts/threads/other_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def replace_hex_in_file(self, input_file, output_file, search_hex, replace_hex):
def yearly_active_sub(self):
patterns = {
r'(getUserAccount\()(.*)(}async getUserAccountFlags)': r'\1\2.then(function(response) {response.subscription={period:"yearly", state:"active"}; response.flags=78; return response;})\3',
r'(getUserAccountFlags\()(.*)(\)\).flags)': r'\1\2\3.then(function(response) {if (response.mask==4) {response.flags=4}; return response;})',
r'(getUserAccountFlags\()(.*)(\)\).flags)': r'\1\2\3.then(function(response) {if(response.mask==4) {response.flags=4}; return response;})',
r'(changeAccountEmail\()(.*)(email:.?,currentPassword:.?}\))': r'\1\2\3.then(function(response) {response.subscription={period:"yearly", state:"active"}; response.flags=78; return response;})',
r'(getPromotion\()(.*)(collectMetrics:!0}\))': r'\1\2\3.then(function(response) {response.components.appBanner=null; response.flags=0; return response;})'
r'(getPromotion\()(.*)(collectMetrics:!\d}\))': r'\1\2\3.then(function(response) {response.components.appBanner=null; response.flags=0; return response;})'
}

# Mapping of patterns to files where they were found: {pattern key: file path}
Expand All @@ -376,18 +376,19 @@ def yearly_active_sub(self):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
if re.search(pattern, content):
print(f"Pattern {pattern} found in file {file_path}")
lines[pattern] = file_path
break
except UnicodeDecodeError:
continue

# Process each file with matched patterns
if all(lines.values()):
print(f"js file patched using yearly_active_sub method: {list(lines.items())[0][1]}")
print("js file patched using yearly_active_sub method")
for pattern, file_path in lines.items():
self.apply_patch(file_path, pattern, patterns[pattern])
else:
print("Pattern not found for yearly_active_sub patch")
print("Not all 4 patterns found for yearly_active_sub patch")
return False

return True
Expand Down

0 comments on commit 57c8447

Please sign in to comment.