Userscript How to prevent the execution of a certain function in inline js?
给我你的怀抱
给我你的怀抱 2017-07-05 10:57:02
0
1
848
// ==/UserScript==

(function() {
    bad = {};
})();

Can be disabled:

<html>
    <body>
        <a onclick="bad();">Click</a>
        <script> 
            bad = function() {alert("bad");}
        </script>
    </body>
</html>

Cannot be disabled:

<html>
    <body>
        <script> 
            bad = function() {alert("bad");}
            bad();
        </script>
    </body>
</html>

How to block the second situation

给我你的怀抱
给我你的怀抱

reply all(1)
洪涛
const bad = {};

This way your function cannot be reassigned. But when assigning a value, an error occurs.

Or try using Proxy.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template