Last active
July 21, 2019 15:09
-
-
Save guangtuan/f325bf3e9f889a96fa6e1475c0073e5a to your computer and use it in GitHub Desktop.
hideSubscriptionProblems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name hide subscription problem on leetcode | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://leetcode.com/problemset/*/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver; | |
const observer = new MutationObserver(function(mutations, observer) { | |
const selectorOfProblem = '#question-app > div > div:nth-child(2) > div.question-list-base > div.table-responsive.question-list-table > table > tbody.reactable-data > tr'; | |
const problems = Array.prototype.slice.call(document.querySelectorAll(selectorOfProblem)); | |
const isSubscription = element => element.querySelector('.fa-lock'); | |
const subscriptionProblems = problems.filter(isSubscription); | |
const hide = element => { | |
element.style.display = 'none'; | |
}; | |
if (subscriptionProblems.length > 0) { | |
subscriptionProblems.forEach(hide); | |
console.log(`hide ${subscriptionProblems.length} subscription problems`); | |
observer.disconnect(); | |
}; | |
}); | |
observer.observe(document, { | |
subtree: true, | |
attributes: true | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the script~