0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

HTMLでQuine

Last updated at Posted at 2023-05-17

前書き

HTMLでQuineを作る。
Chromeでソースと同じ文字列が表示されればよしとする。

というわけで作った。

ソース

quine.html
<script>
s = `
cc = String.fromCharCode;
bq = cc(96);
nl = cc(10);
ltc = cc(60);
gtc = cc(62);
lt = "&l" + "t;";
gt = "&g" + "t;";
br = ltc + "br" + gtc;
s1 = lt + "script" + gt + br + "s = ";
s2 = ";" + br + "eval(s)" + br + lt + "/script" + gt;
s = s1 + bq + s.replaceAll(nl, br) + bq + s2;
document.documentElement.innerHTML = s`;
eval(s)
</script>

結果

別解

ソース

quine2.html
<script>
document.documentElement.innerText = document.getElementsByTagName("script")[0].outerHTML;
</script>

結果

発展記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?