There is no reliable way to prevent a client from modifying, or viewing any data sent to their browser.
I can't find a proper reason to ever want, or need to disable tools such as the F12 Developer tools in chrome. Nor would there ever be a way to perform such an operation so long as you are sending data.
Let's assume through some bug in Chrome, or by using javascript- you are able to disable access to the developer tools. That's great! But what prevents a user, malicious or not, from making a cURL request to your website and just saving the HTML for editing and viewing later? Nothing!
Practices you should follow instead of in-effectively preventing access to developer tools:
- Assume that all data sent to a client, at any time, is being saved indefinitely. This also means that at any time the client may view the source data for your website, for all versions of your website that have ever existed. Never send anything sensitive that may be used later even after the client loses authenticated access.
- Assume that a client may be using a browser that doesn't follow regulations. The browser may not execute or interpret your javascript, or may even modify it before final presentation to an end user.
You should develop your website for compliant browsers, while at the same time understanding that you can't trust the client's javascript to determine if a user should be authenticated to a page or not, that kind of handling needs to occur server side.
- Ensure all pages of your website display the proper copyright and licensing terms. If your worry is theft of all your hard work: While it can be annoying to have a random user steal your website's design after hours of work on it. They are likely going to have little impact on your project. However, clearly stated licensing and copyright prevents anyone working for a company or school project for using your work with or without credit (depending on the licensing).
Even if someone is able to modify the source code for your website.. So what? It shouldn't matter assuming you follow the proper practices and guidelines. Authentication and logic is all handled on the server side of things, and javascript/html should only be used to enhance the user's experince- not perform critical logic or data interactions.