继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

刷新页面,自动刷新页面

紫月青风
关注TA
已关注
手记 2
粉丝 1
获赞 52
<!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 src="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>
打开App,阅读手记
4人推荐
发表评论
随时随地看视频慕课网APP