Skip to content

Instantly share code, notes, and snippets.

@ExtReMLapin
Created March 9, 2022 08:45
Show Gist options
  • Save ExtReMLapin/d56973b38de094d6dc9d44c6a96dcfc9 to your computer and use it in GitHub Desktop.
Save ExtReMLapin/d56973b38de094d6dc9d44c6a96dcfc9 to your computer and use it in GitHub Desktop.
#wrap your .js code inside a function and run this, it's ghetto, it's slow, I couldn't care less
import re
import subprocess
failed = 0
success = 0
input = "_via.js"
with open(input, "r") as f:
content = f.read()
f.close()
matches = re.finditer(" var ", content)
matches_positions = [match.start() for match in matches]
print(matches_positions)
last_working_code = content
for position in matches_positions:
trying_code = (
last_working_code[:position] + " let " + last_working_code[position + 5 :]
)
with open("test_" + input, "w") as f:
f.write(trying_code)
f.close()
process = subprocess.Popen(f"node.exe ./test_{input}", shell=True)
process.wait()
if (process.returncode) == 0:
success += 1
last_working_code = trying_code
else:
failed += 1
print(success + failed, "/", len(matches_positions))
print("Success: " + str(success))
print("Failed: " + str(failed))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment