Skip to main content

✅De-QR.php

Here's a page which helps you decode QR Codes to make sure what you are scanning is safe.

<!DOCTYPE html>
<html>
<head>
  <title>二维码解码器</title>
  <script src="https://cdn.jsdelivr.net/npm/jsqr@1.3.1/dist/jsQR.min.js"></script>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=0.8">
    <style>
        @media (max-width: 980px) {
          body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #007eca;
          }
        }
        @media (min-width: 981px) {
          body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #007eca;
            background-image: url("https://dl.itslittlekevin.com/projects/5069.png");
            background-repeat: no-repeat;
            background-position: right center;
            background-size: auto 100%;
          }
        }
        h1, p, h4 {
          text-shadow: 2px 2px 2px #00000055;
        }
    * {
        color: white;
    }
    button {
        font-size: 15px;
        background-color: #00325565;
        padding: 5px 15px;
        border-radius: 5px;
        border-width: 0px;
        margin: 5px;
        cursor: pointer;
    }
      h4 a {
        text-decoration: none;
    }
      input {
        color: black;
    }    
    #app {
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="app">
    <h1>二维码解码器<br>QR-Decoder</h1>
    <input type="file" id="file" accept="image/*">
    <button id="decode">解码 | Decode</button>
    <p id="result"></p>
    <h4><a href="https://itslittlekevin.com/gadgetslist">»返回工具列表 | Return to Gadgets List«</a></h4>
    <p>© itsLittleKevin · All rights reserved.</p>
  </div>

  <script>
    document.getElementById('decode').addEventListener('click', function() {
      var file = document.getElementById('file').files[0];
      var reader = new FileReader();
      reader.onload = function() {
        var image = new Image();
        image.onload = function() {
          var canvas = document.createElement('canvas');
          canvas.width = image.width;
          canvas.height = image.height;
          var context = canvas.getContext('2d');
          context.drawImage(image, 0, 0, image.width, image.height);
          var imageData = context.getImageData(0, 0, image.width, image.height);
          var code = jsQR(imageData.data, imageData.width, imageData.height);
          if (code) {
            document.getElementById('result').textContent = code.data;
          } else {
            document.getElementById('result').textContent = '无法解码';
          }
        };
        image.src = reader.result;
      };
      reader.readAsDataURL(file);
    });
  </script>
</body>
</html>