Skip to content

Instantly share code, notes, and snippets.

@volante1013
Last active March 14, 2019 22:54
Show Gist options
  • Select an option

  • Save volante1013/94c21d429adf08fae08e3a0f7243062d to your computer and use it in GitHub Desktop.

Select an option

Save volante1013/94c21d429adf08fae08e3a0f7243062d to your computer and use it in GitHub Desktop.
艦これをスマホのブラウザで楽しむためのユーザースクリプト
// ==UserScript==
// @name 艦これフルスクリーン
// @description 艦これをフルスクリーンで開くユーザスクリプト
// @include http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/
// ==/UserScript==
function kc($, _) {
const html = $.documentElement,
gf = $.getElementById('game_frame'),
gs = gf.style,
gw = gf.offsetWidth,
gh = gw * 0.6;
console.log('gw=' + gw + ' gh=' + gh);
let vp = $.querySelector('meta[name=viewport]'),
t = 0;
vp ||
((vp = $.createElement('meta')),
(vp.name = 'viewport'),
$.querySelector('head').appendChild(vp));
vp.content =
'width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no';
html.style.overflow = 'hidden';
$.body.style.cssText = 'min-width:0;overflow:hidden;margin:0';
$.querySelector('.dmm-ntgnavi').style.display = 'none';
$.querySelector('.area-naviapp').style.display = 'none';
$.getElementById('ntg-recommend').style.display = 'none';
$.getElementById('foot').style.display = 'none';
gs.position = 'fixed';
gs.marginRight = 'auto';
gs.marginLeft = 'auto';
gs.right = '0';
gs.zIndex = '100';
gs.transformOrigin = 'top';
if (!_.kancolleFit) {
const k = () => {
// フルスクリーン
var fse;
// プロパティ名の統一
if (document.mozFullScreenElement !== undefined) {
fse = document.mozFullScreenElement; // Firefox
} else if (document.webkitFullscreenElement !== undefined) {
fse = document.webkitFullscreenElement; // Chrome、Safari
}
if (fse === null) {
('orientation' in _ &&
(html.webkitRequestFullscreen &&
html.webkitRequestFullscreen())) ||
(html.mozRequestFullScreen && html.mozRequestFullScreen());
return;
}
const w = html.clientWidth,
h = _.innerHeight;
if (screen.height < h) {
// 横画面
// game_frameを回転させたときのパラメータ
gs.transform = 'scale(' + screen.width / gh + ') rotate(90deg)';
gs.top = w - 9 + 'px';
gs.left = '-' + (screen.height - screen.width) / 2 + 'px';
} else {
// 縦画面でマルチウィンドウ
gs.transform = 'scale(' + w / gw + ')';
gs.top = '25px';
w < gw
? (gs.left = '-' + (gw - w) / 2 + 'px')
: (gs.left = '0');
}
};
_.addEventListener('resize', () => {
clearTimeout(t);
t = setTimeout(k, 1000);
});
_.kancolleFit = k;
}
}
window.onload = kc(document, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment