MakeModableHtml.py 528 B

123456789101112131415161718192021
  1. #!/usr/bin/env python3
  2. import os
  3. import fileinput
  4. import re
  5. import sys
  6. file_path_html = 'glife.html'
  7. file_path_out = 'mods/modable_glife.html'
  8. data = ''
  9. with open(file_path_html, 'r') as file:
  10. data = file.read()
  11. data = re.sub(r"""(<script id="script-sugarcube" type="text/javascript">)(.*?)(</script>)""",r"""\1$.ajax({ url: "mod.html", cache: false}) .done(function( html ) { $( "tw-storydata" ).append( html );\2});\3""",data,1, re.S)
  12. with open(file_path_out, 'w') as file:
  13. file.write(data)
  14. print('Done')