// ==UserScript== // @name sengokuixa-meta // @description 戦国IXAを変態させるツール // @version 1.6.2.1 // @namespace sengokuixa-meta // @include http://*.sengokuixa.jp/* // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js // @website https://github.com/moonlit-g/sengokuixa-meta // @updateURL https://raw.githubusercontent.com/moonlit-g/sengokuixa-meta/master/sengokuixa-meta.meta.js // @grant unsafeWindow // @grant GM_addStyle // @grant GM_openInTab // @grant GM_setClipboard // ==/UserScript== /* 音素材は下記のサイトを利用しています ポケットサウンド様 http://pocket-se.info/ */ (function( $ ) { //■■■■■■■■■■■■■■■■■■■ //■ プロトタイプ //. String.prototype $.extend( String.prototype, { //.. toInt toInt: function() { return parseInt( this.replace(/,/g, ''), 10); }, //.. toFloat toFloat: function() { return parseFloat( this.replace(/,/g, '') ); }, //.. repeat repeat: function( num ) { var str = this, result = ''; for ( ; num > 0; num >>>= 1, str += str ) { if ( num & 1 ) { result += str; } } return result; }, //.. getTime - yyyy-mm-dd hh:mi:ss getTime: function() { if ( !/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test( this ) ) { throw new Error('Invalid string'); } var date = this.replace(/-/g, '/'); return ~~( new Date( date ).getTime() / 1000 ); } }); //. Number.prototype $.extend( Number.prototype, { //.. toInt toInt: function() { return this; }, //.. toFloat toFloat: function() { return this; }, //.. toRound toRound: function( decimal ) { decimal = ( decimal === undefined ) ? 0 : decimal; var num = Math.pow( 10, decimal ); return Math.round( this * num ) / num; }, //.. toFloor toFloor: function( decimal ) { decimal = ( decimal === undefined ) ? 0 : decimal; var num = Math.pow( 10, decimal ); return Math.floor( this * num ) / num; }, //.. toFormatNumber - 9,999,999 toFormatNumber: function( decimal, replaceNaN ) { decimal = ( decimal === undefined ) ? 0 : decimal; if ( isNaN( this ) ) { return replaceNaN || ''; } var num = this.toFloor( decimal ), result = new String( num ); while ( result != ( result = result.replace(/^(-?\d+)(\d{3})/, "$1,$2") ) ); if ( decimal > 0 && num % 1 == 0 ) { result += '.' + '0'.repeat( decimal ); } return result; }, //.. toFormatDate - 0000/00/00 00:00:00 toFormatDate: function( format ) { var date = new Date( this * 1000 ); return date.toFormatDate( format ); }, //.. toFormatTime - 00:00:00 toFormatTime: function( format ) { format = format || 'hh:mi:ss'; var h, m, s; if ( this <= 0 ) { h = m = s = 0; } else { h = Math.floor(this / 3600), m = Math.floor((this - (h * 3600)) / 60 ), s = Math.floor(this - (h * 3600) - (m * 60)); } if ( h >= 100 ) { format = format.replace('hh', h ); } else { format = format.replace('hh', ( '00' + h ).substr( -2 ) ); } format = format.replace('mi', ( '00' + m ).substr( -2 ) ); format = format.replace('ss', ( '00' + s ).substr( -2 ) ); return format; } }); //. Date.prototype $.extend( Date.prototype, { //.. toFormatDate - 0000/00/00 00:00:00 toFormatDate: function( format ) { format = format || 'yyyy/mm/dd hh:mi:ss'; format = format.replace('yyyy', this.getFullYear() ); format = format.replace('mm', this.getMonth() + 1 ); format = format.replace('dd', this.getDate() ); format = format.replace('hh', ( '00' + this.getHours() ).substr( -2 ) ); format = format.replace('mi', ( '00' + this.getMinutes() ).substr( -2 ) ); format = format.replace('ss', ( '00' + this.getSeconds() ).substr( -2 ) ); return format; } }); //. Array.prototype $.extend( Array.prototype, { //.. unique unique: function() { var result = [], temp = {}; for ( var i = 0, len = this.length; i < len; i++ ){ if ( !temp[ this[ i ] ] ) { temp[ this[ i ] ] = true; result.push( this[ i ] ); } } return result; } }); // // prototype.jsがVer1.7未満だとArray→JSON変換で期待した結果にならないため // 同ライブラリで定義されたArray.toJSON()を削除する。 // (window.Arrayが拾えるかはFirefoxのバージョンによって異なるため、拾えてしまった場合のみ) // (Fx24は拾えず、Fx29では拾えるのを確認) // ( function() { if( window.Array ) { if( window.Array.prototype.toJSON ) { delete window.Array.prototype.toJSON; } } })(); //■ jQueryプラグイン //. contextMenu (function($){var timer,defaults={class_menuitem:'imc_menuitem',class_title:'imc_menutitle',class_separater:'imc_separater',class_nothing:'imc_nothing',class_hover:'imc_hover',timeout:800},options=$.extend({},defaults);$.contextMenu=function(_options){options=$.extend({},defaults,_options);return this};$.extend($.contextMenu,{title:function(key){key=key||'';return $('
  • ').addClass(options.class_title).text(key)},separator:function(){return $('
  • ').addClass(options.class_separater)},nothing:function(key){key=key||'';return $('
  • ').addClass(options.class_nothing).text(key)}});$.fn.contextMenu=function(menu,live){if(live){$(document).on('contextmenu',this.selector,collback)}else{this.on('contextmenu',collback)}return this;function collback(e){show.call(this,menu,e);return false}};function show(menu,e){var x=e.pageX,y=e.pageY,menuContainer,containerRight,containerBottom,documentRight,documentBottom;hide();if(typeof(menu)=='function'){menu=menu.call(this,e)}if(menu==null||menu.length==0){return}menuContainer=createMenuList.call(this,menu,e);if(!menuContainer){return}menuContainer.attr('id','imi_contextmenu').css({left:x,top:y}).appendTo('BODY');containerRight=menuContainer.offset().left+menuContainer.width()+10;containerBottom=menuContainer.offset().top+menuContainer.height()+10;documentRight=$(document).scrollLeft()+$(window).width();documentBottom=$(document).scrollTop()+$(window).height();if(containerRight>documentRight){x=x-(containerRight-documentRight);menuContainer.css({left:x})}if(containerBottom>documentBottom){y=y-(containerBottom-documentBottom);menuContainer.css({top:y})}(function(container){var self=arguments.callee;if(container.width()+10>documentRight-container.offset().left){container.css({left:-container.width()-2})}if(container.height()+10>documentBottom-container.offset().top){container.css({marginTop:-container.height()+13})}container.find('> LI > .imc_submenu').each(function(){self.call(self,$(this))})})(menuContainer)}function hide(){var $menu=$('#imi_contextmenu');if($menu.length==0){return}$menu.remove();window.clearTimeout(timer);timer=null};function createMenuList(menu,e,sub){var itemlist=[],$menu;for(key in menu){var menuitem=createMenuItem.call(this,key,menu[key],e);itemlist.push(menuitem.get(0))}if(itemlist.length==0){return null}$menu=$('