-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtensor-build.py
More file actions
79 lines (70 loc) · 2.61 KB
/
Copy pathtensor-build.py
File metadata and controls
79 lines (70 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
"""
将 Tensor 源文件打包成 tensor.js。
"""
import os
def build_tensor():
# 文件顺序
file_order = [
('tensor-src/utils.js', 'utils.js'),
('tensor-src/config.js', 'config.js'),
('tensor-src/bloxd.js', 'bloxd.js'),
('tensor-src/modules/base.js', 'modules/base.js'),
('tensor-src/math.js', 'math.js'),
('tensor-src/game.js', 'game.js'),
('tensor-src/modules/Killaura.js', 'modules/Killaura.js'),
('tensor-src/modules/Scaffold.js', 'modules/Scaffold.js'),
('tensor-src/modules/SlowSwing.js', 'modules/SlowSwing.js'),
('tensor-src/modules/CoordsList.js', 'modules/CoordsList.js'),
('tensor-src/modules/ESP.js', 'modules/ESP.js'),
('tensor-src/modules/Bhop.js', 'modules/Bhop.js'),
('tensor-src/modules/index.js', 'modules/index.js'),
('tensor-src/core/Tensor.js', 'core/Tensor.js'),
('tensor-src/ui.js', 'ui.js'),
('tensor-src/listeners.js', 'listeners.js'),
('tensor-src/loop.js', 'loop.js'),
('tensor-src/index.js', 'index.js')
]
# Tampermonkey 头部
header = """// ==UserScript==
// @name Tensor
// @namespace Scripts
// @match https://*.bloxd.io/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @grant unsafeWindow
// @run-at document-end
// @version 1.0.0
// @author -
// @description Tensor Framework for Bloxd.io
// ==/UserScript==
(() => {"""
# 构建 IIFE 内部内容
parts = []
for file_path, comment_path in file_order:
if not os.path.exists(file_path):
print(f"警告:文件 {file_path} 不存在")
continue
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read().rstrip()
# 添加注释行(缩进两个空格)
parts.append(f' // tensor-src/{comment_path}')
# 添加内容,每行缩进两个空格
indented_content = '\n'.join(' ' + line for line in content.splitlines())
parts.append(indented_content)
# 合并
iife_inner = '\n\n'.join(parts)
full_content = header + '\n\n' + iife_inner + '\n\n})();'
# 写入输出文件
output_file = 'tensor.js'
with open(output_file, 'w', encoding='utf-8') as f:
f.write(full_content)
print(f'已打包到 {output_file}')
# 检查文件大小
if os.path.exists(output_file):
size = os.path.getsize(output_file)
print(f'文件大小: {size} 字节')
if __name__ == '__main__':
build_tensor()