您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
51Talk教师评分:评价量、好评比。 此脚本会在老师的名字后添加2个参数:1、教师标签评价量。2、教师的好评比率(0-100%)。 正在开发中功能:增加过滤功能,高亮显示Top 5的老师。
当前为
// ==UserScript== // @name 51Talk.辅助选老师-有效经验值|好评率|年龄|Top 5 // @version 0.0.15 // @namespace tsharp.js.51talk_sort // @description 51Talk教师评分:评价量、好评比。 此脚本会在老师的名字后添加2个参数:1、教师标签评价量。2、教师的好评比率(0-100%)。 正在开发中功能:增加过滤功能,高亮显示Top 5的老师。 // @author jimbo // @license GPLv3 // @match https://www.51talk.com/ReserveNew/index* // @match http://www.51talk.com/ReserveNew/index* // @icon https://avatars3.githubusercontent.com/u/25388328 // @grant GM_xmlhttpRequest // @require http://code.jquery.com/jquery-3.4.1.min.js // @require https://code.jquery.com/ui/1.12.1/jquery-ui.min.js // ==/UserScript== (function () { 'use strict'; $("head").append( '<link ' + 'href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" ' + 'rel="stylesheet" type="text/css">' ); function sleep(delay) { var start = (new Date()).getTime(); while ((new Date()).getTime() - start < delay) { continue; } } //删除数组中的空元素 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; } /** * 提交运算函数到 document 的 fx 队列 */ var submit = function (fun) { //debugger; var queue = $.queue(document, "fx", fun); if (queue[0] == 'inprogress') { return; } $.dequeue(document); }; let num = /[0-9]*/g; $.each($(".item-top-cont"), function (i, item) { item.innerHTML = item.innerHTML.replace('<!--', '').replace('-->', ''); }); let i_len = $(".item").length; let value = []; var callbacks = []; for (let i = 0; i < i_len; i++) { let j_len = $($(".item")[i]).find(".label").text().match(num).clean("").length; value[i] = 0; for (let j = 0; j < j_len; j++) { value[i] += Number($($(".item")[i]).find(".label").text().match(num).clean("")[j]); } value[i] = Math.ceil(value[i] / 5); $(".teacher-name")[i].innerText += "[" + value[i] + "]"; $($(".item")[i]).attr('label', value[i]); callbacks.push({ 'index': i, 'tid': $(".teacher-details-link a")[i].href.replace("https://www.51talk.com/TeacherNew/info/", "").replace('http://www.51talk.com/TeacherNew/info/', '') }); } $.each(callbacks, function (index, item) { submit(function (next) { // ajax 请求一定要包含在一个函数中 var start = (new Date()).getTime(); $.ajax({ url: window.location.protocol + '//www.51talk.com/TeacherNew/teacherComment?tid=' + item.tid + '&type=bad&has_msg=1', type: 'GET', dateType: 'html', //headers:{'Access-Control-Allow-Origin': window.location.protocol+'//www.51talk.com/TeacherNew/info/'+item.tid,'reference':window.location.protocol+'//www.51talk.com'}, success: function (r) { if ($(".evaluate-content-left span", r) && $(".evaluate-content-left span", r).length >= 3) { var thumbup = Number($(".evaluate-content-left span", r)[1].innerText.match(num).clean("")[0]); var thumbdown = Number($(".evaluate-content-left span", r)[2].innerText.match(num).clean("")[0]); var thumbupRate = ((thumbup + 0.00001) / (thumbdown + thumbup)).toFixed(2) * 100; $(".teacher-name")[index].innerText += "[" + thumbupRate + "%]"; $($(".item")[index]).attr('thumbup', thumbup) .attr('thumbdown', thumbdown) .attr('thumbupRate', thumbupRate) .attr('age', $($('.teacher-age')[index]).text().match(num).clean("")); } else { console.log('Teacher s detail info getting error:' + JSON.stringify(item) + ",error info:" + r); } }, error: function (data) { console.log("xhr error when getting teacher " + JSON.stringify(item) + ",error msg:" + JSON.stringify(data)); } }).always(function () { while ((new Date()).getTime() - start < 800) { continue; } next(); }); }); }); function updateUI() { var l1 = $("#tLabelCount").slider('values', 0); var l2 = $("#tLabelCount").slider('values', 1); var rate1 = $("#thumbupRate").slider('values', 0); var rate2 = $("#thumbupRate").slider('values', 1); var age1 = $("#tAge").slider('values', 0); var age2 = $("#tAge").slider('values', 1); $('#_tAge').html(age1 + " - " + age2); $('#_tLabelCount').html(l1+ " - " + l2); $('#_thumbupRate').html(rate1 + "% - " + rate2+'%'); let tcount=0; $.each($('.item'), function (i, item) { var node =$(item); var l = parseFloat(node.attr('label')); var rate = parseFloat(node.attr('thumbupRate')) var age = parseFloat(node.attr('age')) if ((rate >= rate1 && rate <= rate2) && l >= l1 && l <= l2 && age >= age1 && age <= age2) { if(node.is(':hidden')){ //如果node是隐藏的则显示node元素,否则隐藏 node.css('color','red').show(); }else{ //nothing todo //node.hide(); } tcount++; } else { node.css('color','').hide(); } }); $('#tcount').text(tcount); } value.sort(teacher_sort); submit(function (next) { try { var dialog = $("<div id='dialogs' title='Teacher Filter by Jimbo'>当前可选教师<span id='tcount'>28</span>位<br />有效经验 <span id='_tLabelCount' /><br /><div id='tLabelCount'></div>好评率 <span id='_thumbupRate'/><br /><div id='thumbupRate'></div>年龄 <span id='_tAge' /><br /><div id='tAge'></div></div>"); dialog.appendTo('body'); $("#tLabelCount").slider({ range: true, min: value[value.length-1], max: value[0], values: [ value[value.length-1], value[0]], slide:function(event,ui){ $('#_tLabelCount').html(ui.values[0]+ " - " + ui.values[1]); }, }).on('slidestop', function (event, ui) { updateUI(); }); $("#thumbupRate").slider({ range: true, min: 0, max: 100, values: [0, 100], slide:function(event,ui){ $('#_thumbupRate').html(ui.values[0] + "% - " + ui.values[1]+'%'); }, }).on('slidestop', function (event, ui) { updateUI(); }); $("#tAge").slider({ range: true, min: 0, max: 110, values: [0, 110], slide:function(event,ui){ $('#_tAge').html(ui.values[0] + " - " + ui.values[1]); }, }).on( "slidestop",function (event, ui) { updateUI(); }); dialog.dialog({ // bgiframe: true, resizable: true, //height:300, zIndex: 5000, }); } catch (ex) { } updateUI(); next(); }); })();