为了账号安全,请及时绑定邮箱和手机立即绑定

刷新页面,自动刷新页面

标签:
Html/CSS
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
    <title>刷</title>
    <style>
    html,
    body {
        overflow: hidden;
        padding: 0;
        margin: 0;
        height: 100%;
    }

    iframe {
        width: 100%;
        height: 100%;
        border: none;
    }

    input {
        outline: medium;
        border: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
        -webkit-appearance: textfield;
    }

     ::-webkit-input-placeholder {
        color: #ccc;
    }

     :-moz-placeholder {
        color: #ccc;
    }

     ::-moz-placeholder {
        color: #ccc;
    }

     :-ms-input-placeholder {
        color: #ccc;
    }

    .msg>div {
        display: flex;
        display: -webkit-flex;
        padding: 0 15px;
        margin-top: 15px;
    }

    .msg>div:nth-last-of-type(1) {
        padding-bottom: 15px;
    }

    .msg .name {
        width: 80px;
        line-height: 30px;
    }

    .msg .name.timespan {
        padding-left: 10px;
    }

    .msg .inputdiv {
        flex: 1;
        border: 1px solid #eee;
        padding: 0 10px;
        height: 30px;
    }

    .msg .inputdiv input {
        width: 100%;
        border: none;
        height: 28px;
    }

    .msg .button {
        flex: 1;
        text-align: center;
        border: 1px solid #eee;
        padding: 10px;
    }

    .msg .readnum {
        border: none;
    }

    .msg .readnum span:nth-last-of-type(1) {
        padding-left: 10px;
    }

    .msg .button#button1 {
        border-right: none;
    }

    @media screen and (min-width: 1024px) {
        .msg {
            width: 740px;
            margin-left: auto;
            margin-right: auto;
        }
    }
    </style>
</head>

<body>
    <div class="msg" id="msg">
        <div>
            <div class="name">
                <span>文章地址</span>
            </div>
            <div class="inputdiv">
                <input type="text" placeholder="输入文章地址" id="url">
            </div>
        </div>
        <div>
            <div class="name">
                <span>阅读数量</span>
            </div>
            <div class="inputdiv">
                <input type="number" placeholder="输入你要刷的阅读量" id="coun">
            </div>
        </div>
        <div>
            <div class="name">
                <span>时间间隔</span>
            </div>
            <div class="inputdiv">
                <input type="number" placeholder="输入时间间隔" id="interval">
            </div>
            <div class="name timespan">
                <span>s(秒)</span>
            </div>
        </div>
        <div>
            <div class="button readnum">
                <span>已阅读</span><span id="num"></span>
            </div>
        </div>
        <div>
            <div id="button1" class="button">
                <span>暂停</span>
            </div>
            <div id="button2" class="button">
                <span>开始</span>
            </div>
        </div>
    </div>
    <div id="text">
        <iframe class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="https://18219304774.github.io/addread/remind.html" id="iframe" name='iframe'></iframe>
    </div>
</body>
<script>
var intervalObj = null,
    times = 0;

function ifra(url) {
    var iframe = getId('iframe');
    iframe.src = url;
    var ua = navigator.userAgent.toLowerCase();
    if (/iphone|ipad|ipod|edge/.test(ua)) {
        window.frames['iframe'].location.reload();
    }
}

function read(url) {
    ifra(url);
    times++;
    setReadNum(times);
}

function getId(id) {
    return document.getElementById(id);
}

function star() {
    var url = getId('url').value;
    var coun = Number(getId('coun').value);
    var interval = Number(getId('interval').value) * 1000 || 500;
    if (!url) {
        alert('请输入文章地址');
        return;
    }
    if (!/^(http)/.test(url)) {
        alert('请输入正确的文章地址 (http 开头)');
        return;
    }
    intervalObj = setInterval(function() {
        if (coun && coun <= times) {
            end();
            return;
        }
        read(url);
    }, interval);
}

function end() {
    clearInterval(intervalObj);
}

function setReadNum(num) {
    getId('num').innerText = num;
}

function setIframeHeight() {
    var t = setInterval(function() {
        if (getId('text')) {
            var h = document.body.clientHeight;
            var mh = getId('msg').offsetHeight;
            getId('text').style.height = h - mh + 'px';
            console.log(getId('text').style.height);
            clearInterval(t);
        }
    });
}

function init() {
    setReadNum(0);
    setIframeHeight();
    getId('button2').onclick = star;
    getId('button1').onclick = end;
}
init();
</script>

</html>
点击查看更多内容
4人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消