-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
patch.py
29 lines (25 loc) · 1.05 KB
/
patch.py
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
import os
import glob
import shutil
for path in glob.glob('scratch-gui/build/*.html'):
print(f'Patching HTML {path}')
with open(path, 'r') as f:
contents = f.read()
contents = contents.replace('</head>', '<meta name="robots" content="noindex"></head>')
contents = contents.replace('<link rel="manifest" href="manifest.webmanifest">', '')
with open(path, 'w') as f:
f.write(contents)
for path in glob.glob('scratch-gui/build/**/*.js', recursive=True):
print(f'Patching JS {path}')
with open(path, 'r') as f:
contents = f.read()
contents = contents.replace('https://trampoline.turbowarp.org', 'https://trampoline.turbowarp.xyz')
with open(path, 'w') as f:
f.write(contents)
os.remove('scratch-gui/build/sw.js')
os.remove('scratch-gui/build/manifest.webmanifest')
os.remove('scratch-gui/build/fullscreen.html')
os.remove('scratch-gui/build/embed.html')
os.remove('scratch-gui/build/index.html')
shutil.copy('scratch-gui/build/editor.html', 'scratch-gui/build/index.html')
shutil.copy('robots.txt', 'scratch-gui/build/robots.txt')