首页 > 其他分享 >防扒

防扒

时间:2024-07-08 09:20:51浏览次数:17  
标签: function false callbacks window open fn

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*防扒*/
      (function () {
        var callbacks = [],
          timeLimit = 50,
          open = false;
        setInterval(loop, 1);
        return {
          addListener: function (fn) {
            callbacks.push(fn);
          },
          cancleListenr: function (fn) {
            callbacks = callbacks.filter(function (v) {
              return v !== fn;
            });
          },
        };

        function loop() {
          var startTime = new Date();
          debugger;
          if (new Date() - startTime > timeLimit) {
            if (!open) {
              callbacks.forEach(function (fn) {
                fn.call(null);
              });
            }
            open = true;
            window.stop();
            alert('小黑子,露出鸡脚了吧');
            window.location.reload();
          } else {
            open = false;
          }
        }
      })().addListener(function () {
        window.location.reload();
      });
    </script>
  </body>
</html>

标签:,function,false,callbacks,window,open,fn
From: https://www.cnblogs.com/luckstart/p/18289285

相关文章