Last active
October 1, 2015 05:18
-
-
Save bluelovers/5d0b9eff3d8fbb48388e to your computer and use it in GitHub Desktop.
適用於 使用 html5 canvas 技術的 DMM 遊戲 千年戦争アイギス
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 千年戦争アイギス | |
// @namespace bluelovers | |
// @author bluelovers | |
// | |
// @downloadURL https://gist.github.com/bluelovers/5d0b9eff3d8fbb48388e/raw/%25E5%258D%2583%25E5%25B9%25B4%25E6%2588%25A6%25E4%25BA%2589%25E3%2582%25A2%25E3%2582%25A4%25E3%2582%25AE%25E3%2582%25B9.user.js | |
// @updateURL https://gist.github.com/bluelovers/5d0b9eff3d8fbb48388e/raw/%25E5%258D%2583%25E5%25B9%25B4%25E6%2588%25A6%25E4%25BA%2589%25E3%2582%25A2%25E3%2582%25A4%25E3%2582%25AE%25E3%2582%25B9.user.js | |
// | |
// include http://www.dmm.co.jp/netgame/social/-/gadgets/=/app_id=156462/ | |
// @include http://assets.millennium-war.net/* | |
// | |
// @version 1 | |
// @grant none | |
// run-at document-start | |
// | |
// @require http://code.jquery.com/jquery-latest.js?KU201 | |
// @require https://github.com/bluelovers/UserScript-Framework/raw/develop/UserScript_Framework.user.js?KU201 | |
// | |
// ==/UserScript== | |
(function($, undefined){ | |
$.migrateTrace = false; | |
unsafeWindow.jQuery = $; | |
$(function(){ | |
// UF.log(unsafeWindow.jQuery); | |
$('.emscripten_border:eq(0):has(#canvas)').each(function(){ | |
var _area = $(this); | |
// UF.log(0); | |
var _canvas = $('#canvas', _area); | |
var _timer; | |
var ctrlKey; | |
var _debug = $('<div id="debug"></div>'); | |
var _statusbar = $('<div id="statusbar"></div>').appendTo('.emscripten_border'); | |
var mouseX, mouseY; | |
// UF.log(1); | |
// $(document) | |
// .mousemove(function(event) { | |
// mouseX = event.pageX; | |
// mouseY = event.pageY; | |
// }) | |
// ; | |
_canvas | |
.after(_debug) | |
.attr('oncontextmenu', '') | |
// .on('mousedown mouseup mousemove', function (event) { | |
// status_msg(event, ''); | |
// }) | |
; | |
_debug = $('#debug'); | |
_statusbar = $('#statusbar'); | |
UF.addStyle([ | |
'body { font-size: 10px; }', | |
'#debug { margin: 3px; }', | |
'#debug > a { margin: 0 3px }', | |
'#debug > * { vertical-align: top; }', | |
]); | |
var _a_image = $('<a/>') | |
.attr('href', 'javascript:void(0);') | |
.addClass('btn-point') | |
.text('抓取畫面') | |
.appendTo(_debug) | |
.on('click.image', function () { | |
var dataURL = _canvas.get(0).toDataURL(); | |
var _date = (new Date()).toLocaleFormat('%Y%m%d-%H%M%S'); | |
var _a = $('<a/>') | |
.html(function () { | |
return $('<img/>') | |
.attr('src', dataURL) | |
.height(50) | |
; | |
}) | |
.attr('href', dataURL) | |
.attr('download', 'canvas_' + _date + '.png') | |
.attr('title', _date) | |
.css({ | |
margin: '5px', | |
}) | |
; | |
_debug.append(_a); | |
// UF.log(dataURL); | |
}) | |
; | |
1 && $(window) | |
// .on('keydown keypress', function (event) { | |
// ctrlKey = event.ctrlKey; | |
// | |
// switch (event.which) | |
// { | |
// default: | |
// break; | |
// } | |
// | |
// UF.log(1, event.type, event, mouseY, mouseY, event.which); | |
// | |
// _statusbar.text(event.type + ' [ ' + mouseX + ' , ' + mouseY + ' ] [key: ' + event.which + '] '); | |
// }) | |
.on('keyup', function (event) { | |
ctrlKey = false; | |
switch (event.which) | |
{ | |
case 44: | |
_a_image.triggerHandler('click.image'); | |
break; | |
default: | |
break; | |
} | |
// UF.log(2, event.type, event, mouseY, mouseY, event.which); | |
}) | |
; | |
// document.focus(); | |
}); | |
function status_msg (event, text) | |
{ | |
// UF.log(99, event.type, event, mouseY, mouseY, text); | |
// | |
// _statusbar.text(event.type + ' [ ' + mouseY + ' , ' + mouseY + ' ] [key: ' + event.which + '] ' + text); | |
} | |
function triggerMouseEvent (node, eventType) | |
{ | |
var clickEvent = document.createEvent ('MouseEvents'); | |
clickEvent.initEvent (eventType, true, true); | |
node.dispatchEvent (clickEvent); | |
} | |
})})(jQuery.noConflict()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment