JSFiddle - React, Tailwind, and code Playground

HTML

See console

JavaScript

(function(Math) {
       var random = Math.random; // Original method
       Math.random = function() {
           // use arguments.callee to read source code of caller
           if (/somepattern/.test(arguments.callee.caller)) {
               throw 'Prevented execution!';
           }
           return random.apply(this, arguments); // Generic method proxy
       };
   })(Math);
//]]></script><script>//<![CDATA[
   function ok() {
       return Math.random(); // Passes
   }
console.log(ok());
//]]></script><script>//<![CDATA[
   function notok() {
       var somepattern;
       return Math.random(); // Fails
   }
console.log(notok());