移除LeetCode付费题目

移除LeetCode付费题目, 使不显示在列表中

目前为 2019-07-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         移除LeetCode付费题目
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  移除LeetCode付费题目, 使不显示在列表中
// @author       sumuzhe
// @match        *://leetcode-cn.com/problemset/*
// @grant        none
// ==/UserScript==

// TODO:处理上方输入框及难度选择框等的事件
(function() {
    'use strict';
    main();
})();

function main() {
    remove();
    bindClick();
}

function remove() {
    console.log("remove function...");
    var interval = setInterval(function() {
        var ps = $($(".table,.table-striped > tbody").get(1));
        // console.log(ps);
        // console.log(ps.length);
        if (ps.length === 1) {
            var trs = ps.find("tr");
            // console.log(trs.length);
            for(var i = 0; i < trs.length; i++){
                var tr = $(trs.get(i));
                var spans = $(tr.find("td").get(2)).find("div").children("span");
                for (var j = 0; j < spans.length; j++) {
                    var span = $(spans.get(j));
                    var s = span.children("span");
                    // console.log(s.length);
                    if (s.length == 1){
                        tr.hide();
                    }
                }
            }
            clearInterval(interval);
        }
    }, 500);
}

/**
 * 为翻页按钮及下拉框绑定事件
 */
function bindClick() {
    // 翻页按钮
    var interval = setInterval(function() {
        var btns = $(".pagination-buttons");
        console.log(btns);
        console.log(btns.length);
        if (btns.length > 0) {
            btns.click(function() {
                remove();
            });
            clearInterval(interval);
        }
    }, 500);

    // 下拉框
    var interval2 = setInterval(function() {
        var select = $(".row-selector > .form-control");
        console.log(select);
        console.log(select.length);
        if (select.length > 0) {
            select.click(function() {
                remove();
            });
            clearInterval(interval2);
        }
    }, 500);
}