Kancolle Scaler

艦これのゲーム画面をウィンドウと同じサイズに拡大/縮小

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Kancolle Scaler
// @namespace    http://hisaruki.tumblr.com/
// @version      2
// @description  艦これのゲーム画面をウィンドウと同じサイズに拡大/縮小
// @author       hisaruki
// @match        http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    $("*").css("overflow", "hidden");

    let d = $("<div></div>");
    $("body").append(d);
    d.css("background-size", "cover");
    d.css("width", "100%");
    d.css("height", "100%");
    d.css("position", "absolute");
    d.css("left", "0px");
    d.css("top", "0px");
    d.css("z-index", 2);
    d.css("background", "#fff");

    $("#game_frame").css("position", "fixed");
    $("#game_frame").css("left", "0px");
    $("#game_frame").css("top", "-16px");
    $("#game_frame").css("z-index", 3);
    $("#game_frame").css("transform-origin-x", "left");
    $("#game_frame").css("transform-origin-y", "top");
    $("#game_frame").css("height", "inherit");

    let resize = function(){
        let w = $("#game_frame").width();
        let h = $("#game_frame").height();
        w = 1200;
        //h = 860;
        h = 720;
        let scale = Math.min.apply(null, [
            window.innerWidth / w,
            window.innerHeight / h,
        ]);
        $("#game_frame").css("transform", "scale("+scale+")");
        let left = (window.innerWidth - ($("#game_frame").width() * scale))/2;
        let top = -16 * scale;
        $("#game_frame").css("left", left);
        $("#game_frame").css("top", top);
        return scale;
    }
    resize();
    $(window).resize(function() {
        resize();
    });
})();