Last active
December 18, 2018 10:06
-
-
Save scriptify/32f5ee4ffa61eafc0da8c5b10ada0431 to your computer and use it in GitHub Desktop.
If you don't debug the function using console.log, it throws an unexpected error. But as soon as you want to debug it, it works like a charm (I recently had an occurence like this, and instead of fixing the bug, I needed to create this gist as a joke). "Works" for every global function you create in the browser. Just copy and paste this code int…
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
function notFunny() { | |
function s(fn = () => {}) { | |
return () => { | |
const fnStr = fn.toString(); | |
console.log(fnStr); | |
const keywords = ['console', 'debugger']; | |
if (!keywords.find(key => fnStr.includes(key))) | |
throw new Error(`Uncaught ReferenceError: ${fn.toString().slice(0, 10)} is not defined`); | |
fn(); | |
} | |
} | |
for (let obj in window) { | |
if (typeof window[obj] === 'function') | |
window[obj] = s(window[obj]); | |
} | |
} | |
window.setInterval(notFunny, 300); | |
notFunny(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
o.O