求调脚本
  • 板块灌水区
  • 楼主CSP_Sept
  • 当前回复16
  • 已保存回复16
  • 发布时间2020/5/10 21:37
  • 上次更新2023/11/7 02:41:17
查看原帖
求调脚本
224931
CSP_Sept楼主2020/5/10 21:37

这个脚本的主要用途就是:

  • 不能看题解。
  • 不能做指定难度的题目(比如水题之类的),这里是红橙题。

代码:

// ==UserScript==
// @name         洛谷学术器
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  let luogu be a better place!
// @author       CSP_Sept
// @match        https://www.luogu.com.cn/problem/solution/*
// @match        https://www.luogu.com.cn/problem/*
// @grant        none
// ==/UserScript==

(function() {
     //Writer's luogu uid is 224931.
     'use strict';
     var f=true;
     function strlen(str){
         var len = 0;
         for(var i=0;i<str.length;i++){
             var c = str.charCodeAt(i);
             if((c>=0x0001&&c<=0x007e)||(0xff60<=c&&c<=0xff9f)){
                 len++;
             }
             else{
                 len+=2;
             }
        }
        return len;
     }
    var k=window.location.href;
    for(var i=7;i<strlen(k)-1;i++){
        if(k[i]=='s'&&k[i+1]=='o'){//如果是题解
            window.location.href="https://www.luogu.com.cn";
            f=false;
        }
    }
    const getDifficulty=(pid)=>{//求题目难度
        return $.get(`https://www.luogu.com.cn/problem/${pid}?_contentOnly=1`).then(data => console.log(data.currentData.problem.difficulty))
    }
    if(f==true){
        var ID='';
        var d;
        var f2=0;
        for(var i=0;i<strlen(k);i++){
            if(k[i]>='A'&&k[i]<='Z') f2=1;
            if(f2==1&&(k[i]>='A'&&k[i]<='Z')||(k[i]>='0'&&k[i]<='9')) ID+=k[i];//更新题目编号
        }
        d=getDifficulty(ID);
        if(d>=1&&d<=2) window.location.href="https://www.luogu.com.cn";
    }
})();

求找错,谢谢!

2020/5/10 21:37
加载中...