Greasy Fork

百度自动播放脚本

try to take over the world!

当前为 2019-05-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         百度自动播放脚本
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       You
// @match        https://www.baidu.com/*
// @require      https://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==

(function() {
    'use strict';
  var wh_css = '<style>*{margin:0;padding:0}#wh-bg{position:fixed;width:100%;height:100%;z-index:-999}#wh-bg ul{list-style:none;position:absolute;width:100%;height:100%}#wh-bg li{position:absolute;width:100%;height:100%;opacity:1;transition:all 3s}#wh-bg img{display:block;width:100%;height:auto}#wh-bg .hide{opacity:0!important}</style>';
    $('head').append(wh_css);
    var q=0;
    var i = 0
    function cache(){
        var p = [];
        var po = [];
        for(var j=0;j<=9;j++){
            p[i] = new Image()
            p[i].src = "http://127.0.0.1/state_img/img.php?qq="+i
            console.log('xx',p[i].complete)
            po.push(i)
            i = i+1;
        }
        console.log('已经缓存成功',p)

        if(Object.keys(p).length==10){
            var interval =setInterval(function(){
                $("body").css("cssText","background-image:url(http://127.0.0.1/state_img/img.php?qq="+po[q]+") !important")
                //$("body").css("animation-name","fadein");
                q++
                if(q==9){
                    clearInterval(interval);
                    q = 0;
                    cache()
                }
            },2000);
        }
    }
    cache()

})();