Kanpani Girls Reload Button

Add a button to reload the game.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Kanpani Girls Reload Button
// @namespace    eight04.blogspot.com
// @version      0.1.0
// @description  Add a button to reload the game.
// @author       eight04 <[email protected]>
// @match        http://chienese.kanpanigirls.com/general/game
// @grant        none
// ==/UserScript==

function init() {
    var parent = document.querySelector("#game_canvas"),
        child = document.querySelector("#game_canvas embed");
        
    if (!parent || !child) {
        setTimeout(init, 1000);
        return;
    }

    var button = document.createElement("button");
    button.type = "button";
    button.textContent = "reload";
    button.onclick = function() {
        parent.removeChild(child);
        setTimeout(function(){
            parent.appendChild(child);
        });
    };
    parent.parentNode.insertBefore(button, parent);
}

init();