Greasy Fork

Greasy Fork is available in English.

移除LeetCode付费题目

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

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

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

// TODO: 取消延时执行, 通过监听DOM变动执行代码
(function() {
    'use strict';
    main();
})();

function main() {
    remove();

    // 为翻页按钮绑定事件
    setTimeout(function() {
        console.log($(".reactable-page-button"));
        $(".reactable-page-button").click(function() {
            remove();
        });
    }, 3000);
}

function remove() {
    // console.log($(".table"));
    setTimeout(function() {
        var ps = $($(".table,.table-striped > tbody").get(1));
        var trs = ps.find("tr");
        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();
                }
            }
        }
    }, 3000);
}