major update/remote host the JS and user loader
This commit is contained in:
68
split_script.py
Normal file
68
split_script.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
input_file = '/media/haunter/e11cc3d4-c894-42cd-8c43-fe2cb25293fd/Vcode_raidbot/grepo-remote/GrepolisRemoteControl.user.js'
|
||||
out_dir = '/media/haunter/e11cc3d4-c894-42cd-8c43-fe2cb25293fd/Vcode_raidbot/grepo-remote/bot_modules'
|
||||
|
||||
if not os.path.exists(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
|
||||
with open(input_file, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Find the start of the IIFE
|
||||
start_idx = 0
|
||||
for i, line in enumerate(lines):
|
||||
if line.strip().startswith('(function'):
|
||||
start_idx = i + 1
|
||||
break
|
||||
|
||||
# Extract the body of the IIFE (excluding the last '})();')
|
||||
end_idx = len(lines)
|
||||
for i in range(len(lines) - 1, -1, -1):
|
||||
if line.strip().startswith('})();'):
|
||||
end_idx = i
|
||||
break
|
||||
|
||||
# Remove use strict if present
|
||||
body_lines = [line for line in lines[start_idx:end_idx] if 'use strict' not in line]
|
||||
|
||||
# We will group them manually into files based on logical sections
|
||||
sections = []
|
||||
current_section = []
|
||||
for line in body_lines:
|
||||
current_section.append(line)
|
||||
|
||||
content = "".join(body_lines)
|
||||
|
||||
# Split by known markers
|
||||
blocks = {
|
||||
'00_config.js': [],
|
||||
'01_ui.js': [],
|
||||
'02_state.js': [],
|
||||
'03_captcha.js': [],
|
||||
'04_execute.js': [],
|
||||
'05_main.js': []
|
||||
}
|
||||
|
||||
current_file = '00_config.js'
|
||||
|
||||
for line in body_lines:
|
||||
if '// Toolbar indicator button' in line:
|
||||
current_file = '01_ui.js'
|
||||
elif '// Push town state to relay' in line:
|
||||
current_file = '02_state.js'
|
||||
elif '// Captcha detection' in line:
|
||||
current_file = '03_captcha.js'
|
||||
elif '// Execute: Farm Upgrade' in line:
|
||||
current_file = '04_execute.js'
|
||||
elif '// Poll for and execute pending commands' in line:
|
||||
current_file = '05_main.js'
|
||||
|
||||
blocks[current_file].append(line)
|
||||
|
||||
for filename, lines in blocks.items():
|
||||
with open(os.path.join(out_dir, filename), 'w', encoding='utf-8') as f:
|
||||
f.writelines(lines)
|
||||
|
||||
print("Split completed.")
|
||||
Reference in New Issue
Block a user