// ==UserScript==
// @name 洛谷通过题目比较器 - yyfcpp
// @namespace http://tampermonkey.net/
// @version 1.2.2
// @description 比较你和其他用户在洛谷通过的题目
// @author yyfcpp
// @match https://www.luogu.org/space/*
// @grant none
// @downloadURL none
// ==/UserScript==
/*
* 这是一个注释区,用于保存 TODO 之类的东西
* 如果网络不是很好,可能会出现卡顿的情况。
* 现在使用的是 O(n^2) 的比较算法。如果出现了 AC 了数千题神犇,或许需要改为二分算法。
*/
function clearData(acs) {
var res = new Array();
for (var i = 1; i < acs.length; i++) { // 把每一行非题号字符删掉(从 1 开始循环为了避开 split 之后产生的垃圾)
var tmpStr = "";
for (var j = 0; j < acs[i].length; j++) {
if (acs[i][j] != '"') { // 引号后面的不是题号部分字符
tmpStr = tmpStr.concat(acs[i][j]); // 拼接字符串
} else {
break;
}
}
if (acs[i].length > 50) { // 这是最后一个题目 / 下一个是「尝试过的题目」
res.push(tmpStr);
break;
}
res.push(tmpStr);
}
return res;
}
function extractData(content) {
// 如果你有一个问题打算用正则表达式来解决,那么就是两个问题了。
// 所以窝还是用 split() 解决这一个问题吧!
// var re = new RegExp('\[.*?\]', 'g');
// console.log(re.test(content));
// var acs = content.match('/\[(\S*)\]/');
// var acs = content.match(/^[[A-Z]+[0-9]+<\/a>]/g);
// console.log(acs);
// var acs = content.replace(/\[ 0) { // 对方没开完全隐私保护
compare(hisAc, myAc);
if (hisAc.length >= 1000) { // 对于 1050 通过以下的用户好像无法正常显示
displayAcCntForThousandsShenBen(hisAc.length);
}
}
console.log("对方开启了完全隐私保护,无法比较。");
}
var myUid = document.getElementsByClassName("am-topbar-brand")[0].attributes["myuid"].value; // 获取当前登录账号的 uid
var myUrl = 'https://www.luogu.org/space/show?uid=' + myUid; // 获取自己个人主页的 URL
var nowUrl = window.location.href; // 获取当前所在个人主页的 URL
var hisUid = window.location.href.match(/uid=[0-9]+/)[0].substr(4); // 获取当前所在个人空间主人的 UID
if (myUrl != nowUrl) { // 只有访问他人个人空间才进行比较
work();
} else { // 要对千题神犇们特别添加一个功能
var myAcCnt = getAc(myUid).length
if (myAcCnt >= 1000) {
displayAcCntForThousandsShenBen(myAcCnt);
}
}