Kancolle Scaler

艦これのゲーム画面をウィンドウと同じサイズに拡大/縮小するスクリプト

当前为 2020-12-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         Kancolle Scaler
// @namespace    http://hisaruki.tumblr.com/
// @version      1.1
// @description  艦これのゲーム画面をウィンドウと同じサイズに拡大/縮小するスクリプト
// @author       hisaruki
// @match        http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $("*").css("overflow", "hidden");
    $("#game_frame").css("position", "fixed");
    $("#game_frame").css("left", 0);
    $("#game_frame").css("top", 0);
    $("#game_frame").css("z-index", 32768);
    $("#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;
        let scale = Math.min.apply(null, [
            window.innerWidth / w,
            window.innerHeight / h,
        ]);

        $("#game_frame").css("transform", "scale("+scale+")");
        $("#game_frame").css("left", (window.innerWidth - ($("#game_frame").width() * scale))/2);
        return scale;
    }
    resize();
    $(window).resize(function() {
        resize();
    });
})();