﻿file = r'resources\views\public-test\thankyou.blade.php'
with open(file, 'r', encoding='utf-8') as f:
    c = f.read()

old = '</head>'
new = '''    <script>
        // Prevent back button
        history.pushState(null, null, location.href);
        window.onpopstate = function() { history.pushState(null, null, location.href); };
    </script>
</head>'''

if old in c:
    c = c.replace(old, new, 1)
    print("OK!")
else:
    print("GAGAL")

with open(file, 'w', encoding='utf-8') as f:
    f.write(c)
