// ==UserScript==
// @name NCST教学平台助手
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://elearning.ncst.edu.cn/*
// @grant none
// @downloadURL https://update.greasyfork.icu/scripts/403148/NCST%E6%95%99%E5%AD%A6%E5%B9%B3%E5%8F%B0%E5%8A%A9%E6%89%8B.user.js
// @updateURL https://update.greasyfork.icu/scripts/403148/NCST%E6%95%99%E5%AD%A6%E5%B9%B3%E5%8F%B0%E5%8A%A9%E6%89%8B.meta.js
// ==/UserScript==
(function() {
'use strict';
// 课程列表页面
if (location.pathname === "/meol/lesson/blen.student.lesson.list.jsp") {
let trs = $('#table2 tr');
trs.each(function(index, tr) {
if (index === 0) {
// 标题栏
$(tr).append("
置顶 | ");
} else {
// 行
// 添加置顶按钮
// href="blen.student.lesson.list.jsp?ACTION=LESSUP&lid=46276"
let href = $(tr).find('td .movedown').attr('href')
let result = /lid=([0-9]+)/.exec(href);
let courceId = result[1];
$(tr).append(` | `);
}
})
$('#table2 tr').on('click', '.movetop', function(e) {
let index = e.currentTarget.dataset.index;
let courceId = e.currentTarget.dataset.courceId;
let actionHref = `http://elearning.ncst.edu.cn/meol/lesson/blen.student.lesson.list.jsp?ACTION=LESSUP&lid=` + courceId;
$(this).addClass('loading');
let count = 0;
for (let i = 0; i < (index - 1); i++) {
setTimeout(() => {
$.get(actionHref).then(() => {
count++;
if (count >= (index - 1)) {
$(this).removeClass('loading');
setTimeout(() => {
location.reload();
}, 1000);
}
});
}, 50 * i)
}
})
}
let body = $(document.body);
body.append(`
`);
// Your code here...
})();