Skip to content

Instantly share code, notes, and snippets.

@scriptify
Last active December 18, 2018 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptify/32f5ee4ffa61eafc0da8c5b10ada0431 to your computer and use it in GitHub Desktop.
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…
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();
@dimorphic
Copy link

o.O

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment