Thông Báo Chặn Thao Tác Trên Blogger

1 comment

Chào mọi người.

Hôm nay mình ngồi kiểm tra lại những giao diện blogger thì mình thấy có đoạn code chặn những thao tác của người dùng trên giao diện, và thông báo chuẩn và đẹp mắt dễ nhìn thấy cho mọi người.

Chúng ta bắt đầu nhé.

Mọi người vào trang quản trị giao diện blogger ở mục chỉnh sửa giao diện mọi người thêm đoạn code bên dưới vào trước thẻ , và lưu lại để tận hưởng kết quá.
<!-- chan thao tac hung.pro.vn -->
<style>
  #custom-notification {
      display: none;
      position: fixed;
      top: 20px;
      right: 20px;
      background-color: #f44336;
      color: white;
      padding: 15px;
      border-radius: 5px;
      z-index: 1000;
      font-family: Arial, sans-serif;
      font-size: 14px;
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
      animation: slide-in 0.3s ease, slide-out 0.3s ease 2.7s forwards;
  }

  @keyframes slide-in {
      from {
          opacity: 0;
          transform: translateX(100%);
      }
      to {
          opacity: 1;
          transform: translateX(0);
      }
  }

  @keyframes slide-out {
      from {
          opacity: 1;
          transform: translateX(0);
      }
      to {
          opacity: 0;
          transform: translateX(100%);
      }
  }
</style>
<div id='custom-notification' style='display:none; position:fixed; top:20px; right:20px; background-color:#f44336; color:white; padding:15px; border-radius:5px; z-index:1000; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
  Hotkey disabled.
</div>
<script>
  document.addEventListener('keydown', function (event) {
      // Block F12
      if (event.key === 'F12') {
          event.preventDefault();
          showCustomNotification('F12 bị chặn trên trang blog này.');
      }

      // Block Ctrl+U (View Source)
      if (event.ctrlKey && event.key === 'u') {
          event.preventDefault();
          showCustomNotification('Ctrl+U bị chặn trên trang blog này.');
      }

      // Block Ctrl+Shift+I (DevTools)
      if (event.ctrlKey && event.shiftKey && event.key === 'I') {
          event.preventDefault();
          showCustomNotification('Ctrl+Shift+I bị chặn trên trang blog này.');
      }
      if (event.ctrlKey && event.key === 'p') {
          event.preventDefault();
          showCustomNotification('Printing bị chặn trên trang blog này.');
      }

      // Block Ctrl+C (Copy)
      if (event.ctrlKey && event.key === 'c') {
          event.preventDefault();
          showCustomNotification('Copying content bị chặn trên trang blog này.');
      }

      // Block Ctrl+Shift+C (Inspect Element)
      if (event.ctrlKey && event.shiftKey && event.key === 'C') {
          event.preventDefault();
          showCustomNotification('Ctrl+Shift+C bị chặn trên trang blog này.');
      }
  });

  document.addEventListener('contextmenu', function (event) {
      event.preventDefault();
      showCustomNotification('Chuột phải bị chặn trên trang blog này.');
  });

  function showCustomNotification(message) {
      const notification = document.getElementById('custom-notification');
      notification.textContent = message;
      notification.style.display = 'block';

      // Hide the notification after 3 seconds
      setTimeout(() => {
          notification.style.display = 'none';
      }, 3000);
  }
</script>
<!-- end -->  

Và cuối cùng là mọi người lưu lại giao diện và tận hưởng kết quả.

DEMO THỦ THUẬT TẠI BÀI VIẾT NÀY


Để kiểm tra mọi người click chuột phải, nhấn phím F12, hoặc ctrl + U... để xem kết quả nhé.

Chúc mọi người thành công với tiện ích này.


Lê Hùng
Lê Hùng
Chia sẽ kiến thức và tư duy sáng tạo của bản thân mỗi ngày cho cộng đồng internet Việt Nam và thế giới

1 comment

  1. Mọi người kiểm tra trên bài viết này nhé. <3

    ReplyDelete

Post a Comment

@Partner

Chúng tôi sẽ gỡ liên kết đối với những blog/website vi phạm chính sách & quy định chung về liên kết.