作者: 鐵錨
日期: 2013年12月31日
如題, 使用說明如下:
1. 原創圖書http://special.csdn.net/book2013/yc.html2. 引進圖書http://special.csdn.net/book2013/yj.html//// 採用chrome 開啟以後,右鍵點擊頁面,選擇審查元素// 隨後切換到console控制台// 複製js檔案的所有代碼,在控制台執行即可
指令碼如下:
!(function(){ // 建立script元素 var sc = document.createElement("script"); // 設定屬性 sc.src = "http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"; // 設定載入事件回調 sc.onload = pickVote; // 添加到 body document.body.appendChild(sc); // function Vote(id, name, ding_num){ this.id = id; this.name = name; this.ding_num = ding_num; }; Vote.prototype = { toString : function(){ return this.ding_num + "\t" + this.name ; } }; // function pickVote(e){ if(!$){ alert("很抱歉,新浪伺服器打盹了."); return false; } // var allbook = $(".container .list"); var len = allbook.length; // var allVote = []; // !!allbook.each(function(i,v){ var $this = $(this); // var $name = $("p.black strong",$this); var $ding_num = $(".ding_num", $this); // 書名 var name = $name.text(); var ding_num = $ding_num.text(); // ding_num = parseInt(ding_num); // var vote = new Vote(++i, name, ding_num); allVote.push(vote); }); function desc(x, y){ if (x.ding_num > y.ding_num) { return -1; } else if (x.ding_num < y.ding_num){ return 1; } else { return 0; } }; // 排序 allVote = Array.prototype.sort.call(allVote, desc); // 輸出資訊 var title = document.title; console.info(title+": 排名:"); console.info(allVote.join("\n")); }; }());
資源:
新加了一個測試ITEYE的防DDOS的樣本:
使用說明:
1. 首先 chrome 開啟iteye的某個頁面;這樣才不會出現跨域。2. 然後開啟console3. 粘貼執行重新整理的JS,然後讓頁面一直開著。如果你想要自動重新整理功能,可以使用傲遊瀏覽器。當然,好像搜狗也支援,在標籤頁上點右鍵,自動重新整理即可.
代碼如下:
(function(){var iframe = document.createElement("iframe");iframe.src = "http://damoqiongqiu.iteye.com/blog/1998022";window.document.body.appendChild(iframe);iframe.src= "";var tms = 0;var itv = window.setInterval(function(){iframe.src= "";iframe.src = "http://damoqiongqiu.iteye.com/blog/1998022";tms += 1;if(tms % 500 < 1){console.info("tms="+tms);}}, 0.2 * 1000);}());
一個在瀏覽器測試移動APP的API介面並發的不規範代碼:
(function() {//var $this = $('#apitestform');// 密碼加密var password_clear = $("#password_clear").val() || "";$("#password_md5").val(hex_md5(password_clear));// 新密碼加密var newpassword_clear = $("#newpassword_clear").val() || "";$("#newpassword_md5").val(hex_md5(newpassword_clear));var data = $('#apitestform').serialize();//window.all_time = 0;window.all_num = 0;window.success_num = 0;window.failure_num = 0;//var config = {url : $this.attr("action"),data : data,type : "POST",dataType: "json",beforeSend : function() {},complete : function(xhr,result) {var text = xhr.responseText;var js = JSON.parse(text);if(js && (1 === js.success)){success_num += 1;} else {failure_num += 1;}var pref = window.time || 0;var current = new Date();var time = current.getTime() - pref.getTime();window.all_time += time;//current.getTime() - window.start_time.getTime();var avg_time = Math.round(all_time / all_num);//var log = "all_num="+all_num+"\n"+"success_num="+success_num+"\n"+"failure_num="+failure_num+"\n"+"time="+time+" ms\n"+"all_time="+all_time+" ms\n"+"avg_time="+avg_time+" ms\n";$("#apitestresult").text(log);//window.setTimeout(loop, 0.01 * 1000);}};//function loop(){//window.all_num += 1;window.time = new Date();jQuery.ajax(config);}//window.startTime = 0;window.setTimeout(loop, 0.01 * 1000);}());
請輕拍。