51Talk.教师评分

51Talk教师评分:评价量、好评比

当前为 2019-08-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         51Talk.教师评分
// @version      0.0.1
// @namespace    51talk_sort
// @description  51Talk教师评分:评价量、好评比
// @author       [email protected] and [email protected]
// @license      GPLv3
// @match        https://www.51talk.com/ReserveNew/index*
// @match        http://www.51talk.com/ReserveNew/index*
// @icon         https://avatars3.githubusercontent.com/u/25388328
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    //删除数组中的空元素
    Array.prototype.clean = function(deleteValue="") {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == deleteValue) {
                this.splice(i, 1);
                i--;
            }
        }
        return this;
    };

    function teacher_sort(a, b){
        return b - a;
    }

    let num = /[0-9]*/g;
    let i_len = $(".label").length;
    let value = [];
    for(let i = 0; i < i_len; i++) {
        let j_len = $(".label")[i].textContent.match(num).clean("").length;
        value[i] = 0;
        for(let j = 0; j < j_len; j++) {
            value[i] += Number($(".label")[i].textContent.match(num).clean("")[j]);
        }
        value[i] /= 5;
        $(".teacher-name")[i].innerText += "(" + value[i] + ")";
    }
    console.log(value.sort(teacher_sort));
})();