Last active
August 29, 2015 14:23
-
-
Save puyo-sh/ac7aca974263f2d5ae79 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-DuelBushoPost | |
// @namespace https://github.com/puyo-sh/bro3 | |
// @description ブラウザ三国志 デュエル武将投稿スクリプト(習作) | |
// @include http://*.3gokushi.jp/pvp_duel/duel.php | |
// @version 1.1 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js | |
// ==/UserScript== | |
j$ = jQuery.noConflict(true); | |
(function ($){ | |
// 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 ""; | |
} | |
// 投稿ボタンの設置 | |
$("#duel_deck_tab + div > .deck_fix").append('<a id="one_post_duels" style="background-color:#000000;color:#FFFFFF;padding:3px;">デュエル武将をひとコメに投稿する</a>'); | |
// 投稿ボタンへEvent設定 | |
$("#one_post_duels").off('click').on('click',function(){ | |
// デュエル参加武将情報の取得 | |
var duel_busho = ''; | |
$("#duel_deck_tab + div > .deck_card dt").each(function(){ | |
duel_busho = $(this).html() + ' '; | |
}); | |
// SSID | |
var ssid = getCookie("SSID"); | |
var param = {}; | |
param['ssid'] = ssid; | |
// 参加武将情報をセット | |
param['comment_str'] = duel_busho; | |
// 一言への投稿 | |
$.ajax({ | |
type: 'post', | |
url: '/alliance/chatif.php', | |
data: param, | |
}).then( | |
function(){ | |
alert("投稿しました。リロードする反映されています。"); | |
},function(){ | |
alert("投稿に失敗しました。"); | |
} | |
); | |
}); | |
})(j$); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment