Last active
August 29, 2015 14:23
-
-
Save puyo-sh/63d01262b393a2a071d6 to your computer and use it in GitHub Desktop.
ブラウザ三国志 武将ソートボタン
This file contains 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 3gokushi-BushoSortBtn | |
// @namespace https://github.com/puyo-sh/bro3 | |
// @description ブラウザ三国志 武将ソートボタン | |
// @include http://*.3gokushi.jp/card/deck.php* | |
// @version 1.0 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js | |
// @require http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js | |
// ==/UserScript== | |
j$ = jQuery.noConflict(true); | |
(function ($){ | |
function makeList(param){ | |
// param.category = | |
// ${category} | |
var tmpl_html = (function(){/* | |
<ul id="busho_sort"> | |
<li><a id="" data-sort_order="2">レア</a></li> | |
<li><a id="" data-sort_order="3">Lv</a></li> | |
<li><a id="" data-sort_order="9">攻</a></li> | |
<li><a id="" data-sort_order="10">知</a></li> | |
<li><a id="" data-sort_order="11">歩防</a></li> | |
<li><a id="" data-sort_order="12">槍防</a></li> | |
<li><a id="" data-sort_order="13">弓防</a></li> | |
<li><a id="" data-sort_order="14">騎防</a></li> | |
<li><a id="" data-sort_order="15">速</a></li> | |
</ul> | |
<style> | |
<!-- | |
#busho_sort{ | |
position:absolute; | |
} | |
#busho_sort > li{ | |
float:left; | |
cursor:pointer; | |
} | |
#busho_sort > li > a{ | |
display:block; | |
background-color:#000000; | |
color:#FFFFFF; | |
padding:3px; | |
margin:2px; | |
} | |
--> | |
</style> | |
*/}).toString().replace(/(\n)/g, '').split('*')[1]; | |
var html = $.tmpl(tmpl_html,param) || ''; | |
return html; | |
} | |
// Cookie情報取得Function | |
function getCookie(key){ | |
var cookieString = document.cookie; | |
var cookieKeyArray = cookieString.split(";"); | |
for(var i=0; i < cookieKeyArray.length; i++){ | |
var targetCookie = cookieKeyArray[i]; | |
targetCookie = targetCookie.replace(/^\s+|\s+$/g, ""); | |
var valueIndex = targetCookie.indexOf("="); | |
if(targetCookie.substring(0, valueIndex) == key){ | |
return unescape(targetCookie.slice(valueIndex + 1)); | |
} | |
} | |
return ""; | |
} | |
var html = makeList(); | |
// 投稿ボタンの設置 | |
$("#wrapper").append(html); | |
// 投稿ボタンへEvent設定 | |
$("#busho_sort a").off('click').on('click',function(){ | |
// デュエル参加武将情報の取得 | |
var sort_order = $(this).attr("data-sort_order"); | |
// SSID | |
var ssid = getCookie("SSID"); | |
var param = {}; | |
param['mode'] = ""; | |
param['target_card'] = ""; | |
param['wild_card_flg'] = ""; | |
param['boost_card_flg'] = ""; | |
param['teach_card_flg'] = ""; | |
param['inc_point'] = ""; | |
param['p'] = 1; | |
param['ssid'] = ssid; | |
param['sort_order'] = [sort_order,0]; | |
param['sort_order_type'] = [1,1]; | |
param['show_deck_card_count'] = 103; // 小15 | |
param['btn_change_flg'] = 1; | |
param['l'] = 0; | |
// ソート処理 | |
$.ajax({ | |
type: 'post', | |
url: '/card/deck.php', | |
data: param, | |
}).then( | |
function(){ | |
location.reload(); | |
},function(){ | |
alert("失敗しました。"); | |
} | |
); | |
}); | |
})(j$); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment