-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
130 lines (104 loc) · 5.57 KB
/
index.html
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html>
<head>
<title>PyWTF - Write any Python with only built-in functions.</title>
<meta name="description" content="PyWTF is an esoteric and educational programming style based on JSFuck and inspired by this tweet. It uses only built-in functions to execute code. It currently represents all characters below 0x7f in 48 characters or less in Python 3.9+.">
<meta charset="utf-8" />
<meta property="og:image" content="/preview.png" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/vs2015.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<style>body{padding:20px;background-color:#191919;color:white}*,body{font-family:monospace;font-size:14px;line-height:1.4em}h1{font-size:2em;position:absolute;top:70px;font-weight:normal;left:140px}h2{width:90px;text-align:right;padding:50px 5px 5px;background:#FFD43B;color:#306998;font-weight:bold;font-size:20px;line-height:1em}h3{font-weight:bold}.actions,li,p,textarea{width:100%;max-width:600px}textarea{display:block;height:200px;margin:1em 0}ul.pre li{white-space:pre}.checkbox{display:inline-block}.actions a{float:right}.actions{clear:both}code{color:#ffffff;font-family:monospace, monospace;padding:4px;border-radius:4px}textarea{background-color:#1e1e1e;color:white;font-family:'Courier New', Courier, monospace;border:1px solid #444;padding:10px;width:100%;height:200px;resize:none}pre{max-width:600px;overflow-wrap:break-word;white-space:pre-wrap;word-wrap:break-word;background-color:#1e1e1e;padding:10px;border-radius:5px}a:hover{color:#563ad2!important;border-bottom:1px solid #563ad2!important;text-decoration:none}a{color:#b18af8}</style>
</head>
<body>
<h1>PyWTF</h1>
<h2>()+<br>a-z</h2>
<p>PyWTF is an esoteric and educational programming style based on JSFuck and inspired by <a href="https://x.com/chordbug/status/1834642829919781369">this tweet</a>. It uses only built-in functions to execute code. <b>It currently represents all characters below <code>0x7f</code> in 48 characters or less in Python 3.9+.</b></p>
<p>It does not depend on a browser, so you can run it with Python.</p>
<p>Also a very silly pyjail solver.</p>
<p>Use the form below to convert your own script. Uncheck "Wrap with <code>exec()</code>" to
get back a plain string.</p>
<textarea id="input" value="print('PyWTF')"></textarea>
<button id="encode" type="text">Encode</button>
<div class="checkbox">
<input id="autoencode" type="checkbox" checked/>
<label for="autoencode">Auto-encode</label>
</div>
<div class="checkbox">
<input id="eval" type="checkbox" checked />
<label for="eval">Wrap with <code>exec()</code></label>
</div>
<div class="checkbox">
<input id="period" type="checkbox" />
<label for="period">Allow '.'s</label>
</div>
<div class="checkbox"></div>
<input id="astrix" type="checkbox" />
<label for="astrix">Allow '*'s (not much optimisation yet)</label>
</div>
<div class="checkbox"></div>
<input id="newerPython" type="checkbox" />
<label for="newerPython">Python 3.11+</label>
</div>
<pre><code id="output" class="python"></code></pre>
<div class="actions">
<span id="stats">…</span>
<!-- <a id="run" href="#">Run This</a> -->
</div>
<h3>Links</h3>
<ul>
<li>
Share on
<a href="https://twitter.com/intent/tweet?text=A%20very%20stupid%20project:%20https://pywtf.seall.dev%20%E2%80%93%20Write%20any%20Python%20with%20built-in%20functions%20only%20via%20@sealldev" target="_blank">Twitter</a>
</li>
<li>View source on <a href="http://github.com/sealldeveloper/pywtf">GitHub</a></li>
<li>Follow <a href="http://twitter.com/sealldev">@sealldev</a> (Noah Cooper)</li>
</ul>
<h3>Alternatives</h3>
<ul>
<li><a href="https://theblupper.github.io/pyfuck/">PyFuck</a> (8 chars, browser only)</li>
<li><a href="https://github.com/wanqizhu/pyfuck">pyfuck</a> (13 chars)</li>
</ul>
<h3>Basics</h3>
<ul class="pre">
<li>coming => soon</li>
</ul>
<p>See the full list <a href="https://github.com/sealldeveloper/pywtf/blob/main/pywtf.js">here</a>.</p>
<script src="pywtf.js"></script>
<script>
function reHighlightCode(element) {
element.dataset.highlighted = '';
hljs.highlightElement(element);
}
function encode() {
replaceAndJoin($('input').value)
.then(output => {
$("output").innerHTML = output;
$("stats").innerHTML = output.length + " chars";
document.querySelectorAll('pre code').forEach(el => {
reHighlightCode(el);
});
})
.catch(error => {
console.error('Error in encode function:', error);
$("output").innerHTML = 'An error occurred while processing the input.';
$("stats").innerHTML = '';
});
}
function autoencode() {
const autoencodeEnabled = $('autoencode').checked;
const autoencodeFunction = autoencodeEnabled ? () => setTimeout(encode, 0) : null;
$("input").oninput = autoencodeFunction;
$("eval").onchange = autoencodeFunction;
$("period").onchange = autoencodeFunction;
$("astrix").onchange = autoencodeFunction;
$("newerPython").onchange = autoencodeFunction;
if (autoencodeEnabled) encode();
}
$("encode").onclick = encode;
$('autoencode').onclick = autoencode;
// Initial setup
autoencode();
encode();
</script>
</body>
</html>