NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Userscript1 // @namespace http://tampermonkey.net/ // @version 0.1 // @description Userscript1 // @match https://leetcode.com/* // @grant none // ==/UserScript== /* jshint -W097 */ 'use strict'; function remove(id,className){ if(className!==null && document.getElementsByClassName(className).length>0){ document.getElementsByClassName(className)[0].remove(); } if(id!==null && document.getElementById(id)!==null){ document.getElementById(id).remove(); } } function toggle(element){ if(element.style.display=='none' || element.style.display===''){ element.style.display='block'; }else if(element.style.display=='block'){ element.style.display='none'; } } function toggleEither(id,className){ if(className!==null && document.getElementsByClassName(className).length>0){ toggle(document.getElementsByClassName(className)[0]); } if(id!==null && document.getElementById(id)!==null){ toggle(document.getElementById(id)); } } function createButtonForToggle(id,buttonName){ if(document.getElementById(id)!==null){ document.getElementById(id).style.display='none'; }else if(document.getElementsByClassName(id).length!==0){ document.getElementsByClassName(id)[0].style.display='none'; } else return; // 1. Create the button var button = document.createElement("button"); button.innerHTML = buttonName; // 2. Append somewhere var body = document.getElementsByTagName("body")[0]; body.insertBefore(button, body.firstChild); // 3. Add event handler button.addEventListener ("click", function() { toggleEither(null,id); }); } //remove(null,'navbar'); createButtonForToggle('navbar','nav'); remove('announcement',null); remove(null,'category-group-base'); remove(null,'blog-sidebar'); remove(null,'question-filter-base'); remove(null,'assess-bar'); remove(null,'site-footer'); // document.title = "Google";