tampermonkey油猴定时刷新页面脚本

1,176 阅读1分钟
// @name         60秒刷新一次
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://blog.csdn.net/qq_57150526/article/details/131042140
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    // Your code here...
    function myrefresh()
    {
        window.location.reload();
    }

    function Toast(msg,duration){
        duration=isNaN(duration)?3000:duration;
        var m = document.createElement('div');
        m.innerHTML = msg;
        m.style.cssText="font-size: .32rem;color: rgb(255, 255, 255);background-color: rgba(0, 0, 0, 0.6);padding: 10px 15px;margin: 0 0 0 -60px;border-radius: 4px;position: fixed;    top: 30%;left: 50%;width: 200px;text-align: center;";
        document.body.appendChild(m);
        setTimeout(function() {
            m.style.opacity = '0';
            setTimeout(function() { document.body.removeChild(m) }, duration);
        }, duration);
    }
    (function () {
        setTimeout(function() {
            setTimeout(window.location.reload(),60000);
        }, 60000);//指定60秒刷新一次
        Toast('已开启自动刷新脚本!(60秒)',5000);
    })();
})();