Last active
November 18, 2016 17:21
-
-
Save pupi1985/e463b6982142da7a22004902e25d5e57 to your computer and use it in GitHub Desktop.
refactoring.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| var refactoring = () => { | |
| var node = document.createTextNode("Refactored!"); | |
| var body = document.getElementsByTagName("BODY")[0]; | |
| if (body.hasChildNodes()) { | |
| body.insertBefore(node, body.firstChild); | |
| } else { | |
| body.appendChild(node); | |
| } | |
| }; | |
| // If document was already ready then execute immediately | |
| if (document.readyState === "complete") { | |
| refactoring(); | |
| } else { // If document is not ready then hook the event | |
| document.addEventListener("readystatechange", function (event) { | |
| if (document.readyState === "complete") { | |
| refactoring(); | |
| } | |
| }); | |
| } | |
| }).call(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment