简体   繁体   中英

Modify javascript code chrome dev tools

Is it possible to modify the javascript code in chrome dev tools?

I have created this example, how can i prevent the element from being removed when dev tools are opened? https://jsfiddle.net/2nfw3rau/

var currentInnerHtml;
var element = new Image(); 
var elementWithHiddenContent = document.querySelector("#element-to-hide");
var innerHtml = elementWithHiddenContent.innerHTML;
element.__defineGetter__("id", function() { currentInnerHtml = "";});
setInterval(function() {    currentInnerHtml = innerHtml;                      console.log(element);   console.clear();                    elementWithHiddenContent.innerHTML = currentInnerHtml
}, 1000);

how can i prevent the element from being removed when dev tools are opened

You can't. The user is in control of their browser, not you. If they're using dev tools, they can remove the element (in any of several ways).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM