rpgx_keyboard

Keyboard assist for Taimanin RPGX

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        rpgx_keyboard
// @description Keyboard assist for Taimanin RPGX
// @description:ja 対魔忍RPGXにキーボードでページ送り又はスキップする
// @namespace   http://pc-play.games.dmm.co.jp/play/taimanin_rpgx/
// @include     http://taimanin-rpg.com/game/empty*
// @version     1
// ==/UserScript==
var mouse_down = new window.MouseEvent('mousedown', {view:unsafeWindow,bubbles:true,cancelable:true});
var mouse_up = new window.MouseEvent('mouseup', {view:unsafeWindow,bubbles:true,cancelable:true});
var timeoutId, direction;

function delayLoad()
{
	if (document.getElementById('#canvas')) {
		register();
	} else {
		timeoutId = setTimeout(delayLoad, 1000);
	}
}

function register()
{
	document.addEventListener('keydown', function(event) {
		if (event.keyCode == 17 || event.keyCode == 13) {
	        var canvas = document.getElementById('#canvas');
	        if (canvas) {
				if (event.keyCode == 17) {
					canvas.dispatchEvent(direction? mouse_up : mouse_down);
					direction = !direction;
				} else {
					canvas.dispatchEvent(mouse_down);
				}
				event.preventDefault();
	        }
		}
	});
	document.addEventListener('keyup', function(event) {
		if (event.keyCode == 17 || event.keyCode == 13) {
			var canvas = document.getElementById('#canvas');
			if (canvas) {
				direction = false;
				canvas.dispatchEvent(mouse_up);
				event.preventDefault();
			}
		}
	});
	console.log('rpgx_keyboard loaded.');
}

delayLoad();