🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:12/22 17:49:10
🔄 下次更新时间:12/22 22:49:10
手动刷新缓存

leetcode

leetcode plugin

Per 18-10-2014. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         leetcode
// @namespace    http://redswallow.me/blog
// @version      0.1
// @description  leetcode plugin
// @author       redswallow
// @include      https://oj.leetcode.com/problems/*
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-start
// ==/UserScript==

// 延迟调用函数
var call = function (f) {
  setTimeout.apply(this, [f].concat([0]).concat(Array.apply(Array, arguments).slice(1)));
};

// 设置项
var config = function () {
  var config = {}, storageKey = 'leetcode_plugin_config';
  var onputs = [];
  // 写入到内存
  var put = function (key, value) {
    onputs.map(function (f) { f(key, value, config[key]); });
    config[key] = value;
    return value;
  };
  // 从内存读取
  var get = function (key, value, type) {
    if (!(key in config)) return value;
    var val = config[key];
    if (typeof val === 'undefined') return value;
    if (type && (val === null || val.constructor !== type)) return value;
    return val;
  };
  // 读取到内存
  var read = function () {
    try { config = JSON.parse(GM_getValue(storageKey, '{}')); }
    catch (e) { config = {}; }
  };
  // 从内存写出
  var write = function () {
    GM_setValue(storageKey, JSON.stringify(config));
  };
  // 当内存配置被修改时调用
  var onput = function (f) {
    onputs.push(f);
  };
  // 初始化
  read();
  return {
    'put': put,
    'get': get,
    'read': read,
    'write': write,
    'onput': onput,
  };
};

var html = {
    'acCheckbox' : '<div class="btn-group btn-group-sm" data-toggle="buttons"><label class="btn btn-default active"><input type="checkbox" checked>AC</label><label class="btn btn-default active"><input type="checkbox" checked>WA</label><label class="btn btn-default active"><input type="checkbox" checked>Undo</label></div>',
    'difficultyCheckbox' : '<div class="btn-group btn-group-sm" data-toggle="buttons"><label class="btn btn-default active"><input type="checkbox" checked>Easy</label><label class="btn btn-default active"><input type="checkbox" checked>Medium</label><label class="btn btn-default active"><input type="checkbox" checked>Hard</label></div>',
    'allBtn' : '<div class="btn btn-sm btn-default">All</div>',
    'notAcBtn' : '<div class="btn btn-sm btn-default">!AC</div>',
    'easyBtn' : '<div class="btn btn-sm btn-default">Easy</div>',
    'mediumBtn' : '<div class="btn btn-sm btn-default">Medium</div>',
    'hardBtn' : '<div class="btn btn-sm btn-default">Hard</div>'
}

function init() {
    console.log("init");
    // 加载用户配置
  	//config = config();
    
    var filterDiv = document.createElement('div');
    filterDiv.id = 'filter';
    filterDiv.setAttribute('class','row table-centered col-md-12');
    filterDiv.appendChild(document.createTextNode('Filter :'));
    /*
    var acCheckbox = document.createElement('span');
    acCheckbox.setAttribute('class','table-centered col-md-3');
    acCheckbox.innerHTML = html['acCheckbox'];
    var difficultyCheckbox = document.createElement('span');
    difficultyCheckbox.setAttribute('class','table-centered col-md-3');
    difficultyCheckbox.innerHTML = html['difficultyCheckbox'];
    
    filterDiv.appendChild(acCheckbox);
    filterDiv.appendChild(difficultyCheckbox);
    */
    
    // ac button
    var allBtn = document.createElement('span');
    allBtn.innerHTML = html['allBtn'];
    allBtn.onclick = function() {
        $('tbody tr').show();
    }
    filterDiv.appendChild(allBtn);
    
    var notAcBtn = document.createElement('span');
    notAcBtn.innerHTML = html['notAcBtn'];
    notAcBtn.onclick = function() {
        $('tbody tr').show();
        $('.ac').parent().parent().hide();
    }
    filterDiv.appendChild(notAcBtn);
    // end of not ac button
    
    // difficulty filter
    var easyProblems = $('tbody tr td:last-child[value=1]').parent();
    var mediumProblems = $('tbody tr td:last-child[value=2]').parent();
    var hardProblems = $('tbody tr td:last-child[value=3]').parent();
    
    var easyProblemsBtn = document.createElement('span');
	easyProblemsBtn.innerHTML = html['easyBtn'];
    easyProblemsBtn.onclick = function() {
        easyProblems.show();mediumProblems.hide();hardProblems.hide();
    }
    filterDiv.appendChild(easyProblemsBtn);
    
    var mediumProblemsBtn = document.createElement('span');
    mediumProblemsBtn.innerHTML = html['mediumBtn'];
    mediumProblemsBtn.onclick = function() {
        easyProblems.hide();mediumProblems.show();hardProblems.hide();
    }
    filterDiv.appendChild(mediumProblemsBtn);
    
    var hardProblemsBtn = document.createElement('span');
    hardProblemsBtn.innerHTML = html['hardBtn'];
    hardProblemsBtn.onclick = function() {
        easyProblems.hide();mediumProblems.hide();hardProblems.show();
    }
    filterDiv.appendChild(hardProblemsBtn);
    // end of difficulty filter
    
    var searchResultRowDiv = document.getElementById('searchResultRow');
    searchResultRowDiv.parentNode.insertBefore(filterDiv, searchResultRowDiv);
}

if (document.body) call(init);
else document.addEventListener('DOMContentLoaded', init);

GM_addStyle("#filter span {padding-left:5px; padding-right:5px;}");