cloudflare 301跳转

addEventListener('fetch', event => {
    event.respondWith(fetchAndApply(event.request));
})
async function fetchAndApply(request) {
    var items = ['','',''];

    url = getRandomArrayElements(items, 1) // 需要跳转到的地址

    return Response.redirect(url, 301)
}


function getRandomArrayElements(arr, count) {
    var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
    while (i-- > min) {
        index = Math.floor((i + 1) * Math.random());
        temp = shuffled[index];
        shuffled[index] = shuffled[i];
        shuffled[i] = temp;
    }
    return shuffled.slice(min);
}

posted @ 2022-08-02 20:25  柒丶月  阅读(92)  评论(0编辑  收藏  举报