Jake-E / Fuck New Twitter

// ==UserScript==
// @name         Fuck New Twitter
// @version      0.5
// @description  Make Twitter great again!
// @author       @JakesPlanet
// @match        https://*.twitter.com/*
// @updateURL    https://openuserjs.org/meta/Jake-E/Fuck_New_Twitter.user.js
// @downloadURL  https://openuserjs.org/src/scripts/Jake-E/Fuck_New_Twitter.user.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var isListening = false;

    // Listen for everything related to history state changing, as that's when Twitter fucks it all up again
    if (typeof window.history.pushState === "function") {
        var pushState = window.history.pushState;
        window.history.pushState = function() {
            if (!isListening) { // Don't request another animation frame if there's already one listening
                isListening = true;
                window.requestAnimationFrame(doCheck);
            }
            return pushState.apply(this, arguments);
        };
    }
    if (typeof window.history.replaceState === "function") {
        var replaceState = window.history.replaceState;
        window.history.replaceState = function() {
            if (!isListening) { // Don't request another animation frame if there's already one listening
                isListening = true;
                window.requestAnimationFrame(doCheck);
            }
            return replaceState.apply(this, arguments);
        };
    }
    window.addEventListener("popstate", function() {
        if (!isListening) { // Don't request another animation frame if there's already one listening
            isListening = true;
            window.requestAnimationFrame(doCheck);
        }
    });

    function doCheck() {
        if (document.body.classList.contains("edge-design")) {
            document.body.classList.remove("edge-design");
            isListening = false;
        } else {
            // We haven't detected a change yet
            // Worst case, no change happens and we keep checking
            // isListening should prevent more than instance listening though.
            window.requestAnimationFrame(doCheck);
        }
    }

    if (!isListening) {
        isListening = true;
        window.requestAnimationFrame(doCheck);
    }
})();