Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Remove Subscriber Only Problems From Leetcode
- // @namespace http://tampermonkey.net/
- // @version 0.4
- // @description try to take over the world!
- // @author You
- // @match https://leetcode.com/problemset/all/
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- let tableObserver;
- const tableSelector = ".table-striped";
- const addMutationObserverToDocument = () => {
- if(tableObserver){
- tableObserver.disconnect()
- }
- let targetNode = document.querySelector(tableSelector);
- let observerOptions = {
- childList: true,
- subtree: true
- }
- let callback = (mutationList, observer) => {
- mutationList.forEach((mutation) => {
- if (mutation.type == 'childList') {
- targetNode.querySelectorAll('tr').forEach((row, index) => {
- if (row.cells.length>=3 && row.cells[2].querySelectorAll("i[class~='fa-lock']").length) {
- try{
- row.parentElement.removeChild(row);
- }
- catch(e){'I am bad';}
- }
- })
- }
- })
- }
- tableObserver = new MutationObserver(callback);
- tableObserver.observe(targetNode, observerOptions);
- }
- let docObserver = new MutationObserver((mutationList, observer) => {
- mutationList.forEach((mutation) => {
- if (mutation.type == 'childList') {
- if (document.querySelectorAll(tableSelector).length) {
- addMutationObserverToDocument();
- }
- }
- })
- });
- docObserver.observe(document, {
- childList: true,
- subtree: true
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement