随机访问

前面的文章有提到过随机访问链接,我作用在了友链上面,可以进入友链页面体验。
但这个是根据读取[友情链接]插件的数据库信息实现的,下面分享一个不用数据库的版本,基于travellings修改。

创建一个js文件,填入以下内容:

function travelling() {
  var url = new Array();

  url[0] = "https://loli.ma";
  url[1] = "https://dalao.net";
  url[2] = "https://dai.ge";
//   url[递增序号] = "链接";

  if (document.referrer) {
    var origin = new URL(document.referrer).origin;
    if (url.includes(origin)) {
      url.splice(url.indexOf(origin), 1);
    }
  }
  var ints = Math.floor(Math.random() * url.length);
  window.location = url[ints];
}

然后创建一个中转页面,复制以下内容:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机访问</title>
    <script src="js/web.js"></script><!--填你刚刚创建的js路径-->
<style>
        * {
            color: #111827;
        }
        a {
            text-decoration: none;
        }
        .blink {
            position: fixed;
            height: 100%;
            width: 100%;
            text-align: center;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
            animation: blink 3s linear infinite;
            -webkit-animation: blink 3s linear infinite;
            -moz-animation: blink 3s linear infinite;
            -ms-animation: blink 3s linear infinite;
            -o-animation: blink 3s linear infinite;
        }
    </style>
</head>
<body>
    <div class="blink">
        正在进入…
    </div>
    <script language="javascript">
        window.setTimeout("window.location.href='javascript:travelling()'", 5);
    </script>
</body>
</html>

大功告成,访问试试吧!