Javascript Anti View Source Kode Script Blog Website

InShot 20240422 022846035 Copy
Preventing users from viewing the source code of a website is a challenging task because browsers are designed to display the source code to users. However, you can implement measures to discourage or make it more difficult for users to view the source code.
Here are some strategies you can use:
1. **Disable Right Click:**
 This prevents users from right-clicking to view the source.
2. **Disable Keyboard Shortcuts:**
 Prevents the use of shortcuts like `Ctrl+U`, `Ctrl+Shift+I`, `F12`, etc.
3. **Obfuscate JavaScript Code:**
 Makes the code harder to read.
4. **Prevent Developer Tools:**
 Attempt to detect and block the opening of developer tools.
Here’s a basic example combining these methods:
“`html
<a href="https://b-tc.my.id/youtuber/anti-view-source/">anti view source</a> Website

Welcome to My Website

This content is protected.

“`
### Explanation:
1. **Disable Right Click:**
 “`javascript
 document.addEventListener(‘contextmenu’, function(e) {
 e.preventDefault();
 });
 “`
 This prevents the context menu from appearing when the user right-clicks.
2. **Disable Keyboard Shortcuts:**
 “`javascript
 document.addEventListener(‘keydown’, function(e) {
 if (e.keyCode === 123 ||
 (e.ctrlKey && e.shiftKey && e.keyCode === 73) ||
 (e.ctrlKey && e.shiftKey && e.keyCode === 74) ||
 (e.ctrlKey && e.keyCode === 85)) {
 e.preventDefault();
 }
 });
 “`
 This blocks the `F12` key, `Ctrl+Shift+I` (to open Developer Tools), `Ctrl+Shift+J` (to open the JavaScript Console), and `Ctrl+U` (to view the page source).
3. **Prevent Developer Tools:**
 “`javascript
 (function() {
 function detectDevTools(allow) {
 if (isNaN(+allow)) return;
 let start = +new Date();
 debugger;
 let end = +new Date();
 if (end – start > 100) {
 document.body.innerHTML = ‘

Blocked

’;
 window.location.reload();
 }
 }
 setInterval(detectDevTools, 1000);
 })();
 “`
 This script repeatedly checks if the debugger has been activated, which happens when the developer tools are opened. If detected, it reloads the page or displays a message.
### Important Note:
These methods only provide a deterrent and can be bypassed by determined users. Browsers are inherently designed to allow users to view and interact with HTML, CSS, and JavaScript, so it’s impossible to completely prevent access to the source code. For sensitive operations, always ensure the security of your backend and server-side code.

Rating





Baca Juga Javascript Script Anti Copy Paste Artikel Website Blog


Related posts:

2 thoughts on “Javascript Anti View Source Kode Script Blog Website

Leave a Reply

Your email address will not be published. Required fields are marked *