LoginSignup
163
164

More than 5 years have passed since last update.

Web魚拓が作られた時に、魚拓内容を書き換え強制リダイレクトする

Last updated at Posted at 2015-11-02

Web魚拓超怖い。元ネタ削除前に魚拓されると、ずっと残り続けます。今年に入っても某退職エントリとか...サイトミラーリングの対策を実行されたこちらのエントリをより汎用的にしたコードです。ドメイン名が異なると非表示になるためミラーサイト対策にもなります。

魚拓元のサイト

http://subc.github.io/gyotaku/

Web魚拓結果

魚拓しましたがコンテンツが非表示になっていてます。
http://megalodon.jp/2015-1102-1443-25/subc.github.io/gyotaku/
スクリーンショット 2015-11-02 15.10.11.png

ソースコード

deny.js

// ホストネームに含まれる文字列
host_name = 'github.io';

// コピーされたときのredirect先
redirect_deny_url = 'http://megalodon.jp/';
redirect_millisec = 5000;

// コピーされたときに表示するメッセージ
deny_message = '<h3>本ページは削除されました。(・ω<) テヘペロ </h3>';


function main(){
    // ローカルなら動かさない
    if ($(location).attr('hostname') == ''){
        console.info('is local');
        return null;
    }

    // ホストが異なるなら実行
    if ($(location).attr('hostname').match(host_name)){
        // 正常
        console.info('my site');
        return null;
    }else{
        // コピーサイト
        console.info('copy site');
        disable();
    }
}

function disable(){
    console.info('start disable');
    // div.mainを書き換え
    $("div.main").html(deny_message);
    // 5秒後にredirect
    setTimeout(function(){
        $(document).ready( function() {
            $(location).attr("href", redirect_deny_url);
        });
    },redirect_millisec);
}

$(main);

index.html
<html>
<head>
<title>Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="./deny.js"></script>
<body>

<div class="main">
    <p style="margin: 100px">
    土星レイドハードのオリックス強すぎてギスギス絆崩壊ハロウィーン...<br />
    <img src="http://livedoor.blogimg.jp/games084/imgs/0/d/0d3cf4ec.jpg">
</div>

</body>
</html>

完全に消える訳ではない

非表示になるだけで、ソースを見るとデータが残っているので復元できてしまいます。
スクリーンショット 2015-11-02 15.13.54.png

163
164
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
163
164