<script>
function checkWeight() {
    var maxAttempts = 100; 
    var today = new Date();
    today.setHours(0, 0, 0, 0); 
    var expires = new Date(today.getTime() + (24 * 60 * 60 * 1000)); 

    var attempts = getCookie("attempts"); 
    if (attempts === null) {
        attempts = 0;
    }
    if (attempts >= maxAttempts) {
        if (confirm("免费用户只能查询" + maxAttempts + "次,是否升级为付费用户?")) {
            window.location.href = "upgrade.html";
        } else {
            document.getElementById("input-link").disabled = true;
            document.getElementById("check-btn").disabled = true;
            alert("您已超过免费查询次数,请升级为付费用户或明天再来!");
        }
        return;
    }

    var url = document.getElementById("input-link").value.trim();
    if (url.length > 0) {
        if (/[\u4e00-\u9fa5]/.test(url)) {
            alert("输入的链接不能包含汉字,请重新输入!");
            return false;
        }
        if (/(http(s)?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(url) === false) {
            alert("输入的链接格式不正确,请重新输入!");
            return false;
        }
        var newUrl = "ks.php?url=" + encodeURIComponent(url);
        location.href = newUrl;
        setCookie("attempts", ++attempts, expires); 
    } else {
        alert("请输入抖音主页分享链接。");
    }
}

function getCookie(name) {
    var pattern = new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$");
    return decodeURIComponent(document.cookie.replace(pattern, "$1")) || null;
}

function setCookie(name, value, expires) {
    document.cookie = name + "=" + encodeURIComponent(value) + "; expires=" + expires.toUTCString() + "; path=/";
}
</script>
我希望下列这段js代码不允许输入汉字与链接清除空格等操作希望ai重新写成完整版scriptfunction checkWeight var maxAttempts = 100; var today = new Date; todaysetHours0 0 0 0; var expires = new DatetodaygetTime + 24 60 60 100

原文地址: https://www.cveoy.top/t/topic/0Ba 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录