Skip to content

Instantly share code, notes, and snippets.

@guangtuan
Last active July 21, 2019 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guangtuan/f325bf3e9f889a96fa6e1475c0073e5a to your computer and use it in GitHub Desktop.
Save guangtuan/f325bf3e9f889a96fa6e1475c0073e5a to your computer and use it in GitHub Desktop.
hideSubscriptionProblems
// ==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
});
})();
@izackwu
Copy link

izackwu commented Jul 21, 2019

thanks for the script~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment