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?

いろんなコードを動かなくするサイト

Posted at

どうもAtsu1209です。
今回はコード破壊ツールを作ります。(?)

コード

 function uglifyCode() {
            const x = document.getElementById('inputCode').value;
            let a = x.replace(/\s+/g, ' ');
            a = a.replace(/\/\*.*?\*\//g, '');
            a = a.replace(/\/\/.*(?=\n)/g, '');
            
            var result = "";
            for (let i = 0; i < a.length; i++) {
                if (i % 2 === 0) {
                    result += a[i].toUpperCase();
                } else {
                    result += a[i].toLowerCase();
                }
            }
            document.getElementById('outputCode').value = (function(n){return n;})(result);
        }

変数をaにしてちょっとだけクソコード要素入れておきました。

使ってみる

今回入力するコード

function generateHTML() {
    const title = document.getElementById('title').value;
    const date = document.getElementById('date').value;
    const content = document.getElementById('content').value;
    
    const generatedHTML = generateBlogPage(title, date, content);
    
    document.getElementById('output').value = generatedHTML;
}

PCの中に転がってた何かしらのJSコード

出力
FuNcTiOn gEnErAtEhTmL() { CoNsT TiTlE = DoCuMeNt.gEtElEmEnTbYiD('tItLe').vAlUe; CoNsT DaTe = dOcUmEnT.GeTeLeMeNtById('DaTe').vAlUe; CoNsT CoNtEnT = DoCuMeNt.gEtElEmEnTbYiD('cOnTeNt').vAlUe; CoNsT GeNeRaTeDhTmL = GeNeRaTeBlOgPaGe(tItLe, DaTe, CoNtEnT); DoCuMeNt.gEtElEmEnTbYiD('oUtPuT').VaLuE = GeNeRaTeDhTmL; }

もしかしたらGithubPagesで公開するかも

0
0
2

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?