Skip to content

Instantly share code, notes, and snippets.

@twinsant
Created March 19, 2021 01:39
Show Gist options
  • Select an option

  • Save twinsant/1b534a71e8eb1820d01ac1183b6b80e6 to your computer and use it in GitHub Desktop.

Select an option

Save twinsant/1b534a71e8eb1820d01ac1183b6b80e6 to your computer and use it in GitHub Desktop.
百度AI开发者社区数据统计
// ==UserScript==
// @name AI.Baidu
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 百度AI开发者社区数据统计
// @author twinsant
// @match https://ai.baidu.com/forum
// @grant none
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// ==/UserScript==
function parseNum(t) {
let r = /\d+$/;
var num = parseInt(t.match(r).join(""));
return num;
};
$(document).ready(function(){
$(".forum-operation-guide-info").each(function(i){
let name = $(this).find(".forum-operation-module-name").text();
$(this).find(".forum-operation-guide-heat").each(function(i){
var t = $(this).find(".forum-operation-post-num").text();
var post_num = parseNum(t);
var e = $(this).find(".forum-operation-reply-num")
t = e.text().trim();
if (t === "") {
return;
} else {
var reply_num = parseNum(t);
}
var avg = reply_num / post_num;
e.text("回复:" + reply_num + " / " + avg.toFixed(2));
localStorage.setItem(name, reply_num);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment