learn.co banner killer

Kills annoying lower banner element

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name learn.co banner killer
// @description Kills annoying lower banner element
// @namespace learn_co
// @include http://learn.co/*
// @include https://learn.co/*
// @include http://*.learn.co/*
// @include https://*.learn.co/*
// @version 1
// @run-at  document-body
// @grant   none
// ==/UserScript==

/* To learn.co students:
the @include defines the url in which the script will operate.
Don't forget to include it (remember asterisks define anything that will come after it,
so if learn.co/lessons/etc is after learn.co the script will still run on that url and beyond.
*/

/*
we pass the className parameter to define our class in the html div.
typically itll be div id or div class, it depends but it doesnt matter,
but make sure you inspect the elements you want to remove in the console,
because if its a div class you will need to use the 
``` removeElementsByClass ``` method, otherwise its byID. 

in this example, the banner we want to remove at the bottom has a classname
which is "site-banner site-banner--bottom util--show-medium-up" - so thats
what we want to remove.
*/
(function removeElementsByClass(className) {
    'use strict';
    className = 'site-banner site-banner--bottom util--show-medium-up';

    // we want to grab the element, so we pass className to our elementToRemove
    // then we enter our loop
    // however, we need to remove the parent first in order
    // to remove the child
    // i'm not 100% on the reason why, i dont think it was always like this but
    // i think something changed from the documentation i read, but basically
    // make sure you always remove the parent, too.
    // then we basically remove the child (the element we defined)

    // very basic, functional js script!
    // i encourage everyone learning js to get familiar with the
    // getElements methods, they are very useful,
    // and to check out the further documentation on MDN
    var elementToRemove = document.getElementsByClassName(className);
    while(true){
        elementToRemove[0].parentNode.removeChild(elementToRemove[0]);
    }
})();