markdown测试:javascript代码着色

代码来自:http://www.cnblogs.com/tt-0411/p/3580119.html

// ==UserScript==
// @name       yunpan-qun
// @version    0.1
// @include    http://qun*.yunpan.360.cn/group/index*
// @run-at document-end
// ==/UserScript==

(function(){ 
    var ypsi = function(){
        var post = function(url, gid){
            var req = new XMLHttpRequest();
            req.onreadystatechange = function(){
                if(req.readyState == 4){
                    // console.log(req.responseText);
                    var o = JSON.parse(req.responseText);
                    var text = gid + "\t" + o["errmsg"];
                    var size = o["data"] ? o["data"]["size"] : null;
                    if(size) text += "\t" + (size / 1024 / 1024);
                    console.log(text);
                }
            }
            req.open("POST", url, true);
            req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            req.send("gid=" + gid)
        };
        
        var lastday = GM_getValue("yunpan-lastday", "");
        var today = (new Date()).format("YYYYMMdd");
        GM_setValue("yunpan-lastday", today);
        if(lastday && lastday == today ){
            console.log("Today signed.");
        } else {
            var groups = document.querySelectorAll("#groupPanel .group-item");
            [].forEach.call(groups, function(e){
                var gid = e.dataset["gid"];
                post("/group/signIn", gid);
            });
        }
        console.log("done");
    };
    setTimeout(ypsi, 3000);
})();
posted @ 2014-07-23 11:08  博客园团队  阅读(2750)  评论(3编辑  收藏  举报