alay9999 / 颈椎病防治小工具_V 友专版

// ==UserScript==
// @name         颈椎病防治小工具_V 友专版
// @namespace    http://www.zji.me/
// @version      0.1
// @description  没啥可说的,试试就知道了,
// @author       You
// @match        *://www.v2ex.com/*
// @grant        none
// @require      http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.3.min.js
// ==/UserScript==
var htmltag = new RegExp("\<");
var endtag = new RegExp("\>");
$(document).ready(function(){
    $("body").prepend('<div id="hahaha" style="width:100%;text-align:center;background:#eb7350;color:#FFF;padding:30px 0;font-size:20px;">为了广大读者们的健康着想,本站特别开发了颈椎保护阅读模式<br>点击下方按钮开启(特别提醒:本功能内测期间,此消息仅部分用户可见)<br><br><button id="gogogo">开启颈椎保护模式,充分保护颈椎健康</botton></div>');
    $("#gogogo").click(function(){
        $("#hahaha").remove();
        var htmlcode = $("body").html().split("<");
        var scode = "";
        for (var k = 0; k < htmlcode.length; k++) {
            var i = Math.floor(Math.random()*4)*90;
            if(k == htmlcode.length-1){
                var mm ="";
            }else{
                var mm ="<";
            }
            if(htmlcode[k] != ""){
                if(endtag.test(htmlcode[k])){
                    var htcode = htmlcode[k].split(">");
                    if(htcode[1] != undefined){
                        htcode[1] = htcode[1].replace(/[\u4e00-\u9fa5]/g,'<div style="display:inline-block;padding:0;margin:0;transform:rotate('+i+'deg)">$&</div>');
                    }else{
                        htcode[1] = "";
                    }
                    scode += htcode[0]+">"+htcode[1]+mm;
                }else{
                    if(htmlcode[k] != undefined){
                        var kk = htmlcode[k].replace(/[\u4e00-\u9fa5]/g,'<div style="display:inline-block;padding:0;margin:0;transform:rotate('+i+'deg)">$&</div>');
                    }else{
                        var kk = "";
                    }
                    scode += kk +mm;
                }
            }else{
                scode += mm;
            }
            
        }
        $("body").html(scode);
    });
});