期末考試了,可是你知道么,登成績也是很讓人蛋疼的一件事情啊

尤其是在網路及其不穩定的時候。

所以我就用自己稍稍懂一點點的javascript寫了一些代碼,讓成績的錄入一次完成。

當然這個是在現代瀏覽器才能實現,ie的話比較麻煩。

如果是qq瀏覽器的話就是出現這個閃電箭頭才行

進入成績登錄的頁面以後呢,在輸入的區域點右鍵,選擇檢查:

之所以這麼做是因為這個系統是用了iframe的,所以要先在frame裡面點一下右鍵,才能讓console進這個frame

然後應該就可以看到這個界面了,在最下面的那個>後面輸入下面的代碼:

var a = document.getElementById("DataGrid1")var trlist = Array.from(a.children[0].children)var datasrc = [{name:"##",hwd:80,fnl:59}, {name:"###",hwd:87,fnl:74}, {name:"###",hwd:85,fnl:87}, {name:"###",hwd:87,fnl:55}, {name:"###",hwd:85,fnl:74}, {name:"###",hwd:84,fnl:94}, {name:"###",hwd:86,fnl:86}, {name:"###",hwd:84,fnl:92}, {name:"###",hwd:84,fnl:89}, {name:"###",hwd:80,fnl:77}, {name:"##",hwd:84,fnl:81}, {name:"###",hwd:84,fnl:80}, {name:"###",hwd:86,fnl:90}, {name:"###",hwd:92,fnl:84}, {name:"###",hwd:90,fnl:78}, {name:"###",hwd:92,fnl:83}, {name:"###",hwd:80,fnl:86}, {name:"###",hwd:90,fnl:79}, {name:"###",hwd:89,fnl:85}, {name:"###",hwd:88,fnl:90}, {name:"###",hwd:88,fnl:88}, {name:"###",hwd:86,fnl:72}, {name:"###",hwd:85,fnl:88}, {name:"###",hwd:89,fnl:93}, {name:"###",hwd:85,fnl:92}, {name:"###",hwd:85,fnl:79}, {name:"###",hwd:88,fnl:85}, {name:"###",hwd:86,fnl:67}, {name:"###",hwd:84,fnl:83}, {name:"###",hwd:88,fnl:61}, {name:"###",hwd:89,fnl:81}, {name:"###",hwd:89,fnl:75}, {name:"###",hwd:80,fnl:71}, {name:"###",hwd:92,fnl:70}, {name:"###",hwd:85,fnl:78}, {name:"###",hwd:92,fnl:84}, {name:"###",hwd:83,fnl:74}, {name:"###",hwd:86,fnl:84}, {name:"###",hwd:86,fnl:95}, {name:"###",hwd:85,fnl:86}, {name:"###",hwd:85,fnl:76}, {name:"###",hwd:84,fnl:78}, {name:"###",hwd:84,fnl:67}, {name:"###",hwd:86,fnl:91}, {name:"###",hwd:0,fnl:0}, {name:"###",hwd:86,fnl:75}, {name:"###",hwd:78,fnl:98}, {name:"###",hwd:78,fnl:97}, {name:"###",hwd:86,fnl:92}, {name:"###",hwd:86,fnl:91}, {name:"###",hwd:86,fnl:87}, {name:"##",hwd:83,fnl:71}, {name:"##",hwd:85,fnl:84}, {name:"###",hwd:86,fnl:74}]trlist.forEach(e=>{ var entry = datasrc.filter(ent => ent.name == e.children[3].innerText) if(entry.length>0){ e.children[4].children[0].value = entry[0].hwd e.children[7].children[0].value = entry[0].fnl }})

這個是根據佛大的100網輸入系統做的微調,其實程序很簡單,就是根據dom樹找到對應的input元素,修改value值就可以完成輸入了。

當然datasrc這個變數要自己去做。我是在excel裡面把成績登記好,然後提取裡面的平時成績和期末成績,加上姓名總共三列擺在一起,複製到一個文本文檔裡面,之後使用下面的正則做一次轉化:

查找使用:

([u4e00-u9fa5]+)t(d+)t(d+)

替換使用:

{name:"$1",hwd:$2,fnl:$3},

把各行join起來,最後面的,也去掉,兩側加上[]形成一個數組,之後就可以用了。


當然了,現在還是非常不自動呢,有空的時候看看能不能用selenium改進一下。

更新一下

發現一個bug,現在是按照名字作filter,遇到重名就麻煩了,還是應該用學號才好

推薦閱讀:

TAG:辦公自動化 | 期末考試 |