Created
July 28, 2014 02:49
-
-
Save 5zen/97b8dec958254c058dd4 to your computer and use it in GitHub Desktop.
ブラウザ三国志 自動デュエル 2014.07.28
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 bro3_duel | |
// @namespace ブラウザ三国志 自動デュエル | |
// @version 2014.07.28 | |
// @include http://*.3gokushi.jp/village.php* | |
// @include https://*.3gokushi.jp/village.php* | |
// @include http://*.nexon.com/village.php* | |
// @icon https://raw.github.com/gozen-bro3/GlobalGraphicData/master/icon.png | |
// @description ブラウザ三国志 自動デュエル | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_xmlhttpRequest | |
// @grant GM_addStyle | |
// @grant GM_getResourceURL | |
// ==/UserScript== | |
// *** Attention *** | |
// 拠点表示の度にデッキ1を利用してデュエルを1回行う。 | |
// デッキ1にカードがすべてセットされていない場合には動作を行わない。 | |
// 2014.07.28 適当にリリース | |
/*! | |
* jQuery Cookie Plugin | |
* https://github.com/carhartl/jquery-cookie | |
* | |
* Copyright 2011, Klaus Hartl | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://www.opensource.org/licenses/mit-license.php | |
* http://www.opensource.org/licenses/GPL-2.0 | |
*/ | |
(function($) { | |
$.cookie = function(key, value, options) { | |
// key and possibly options given, get cookie... | |
options = value || {}; | |
var decode = options.raw ? function(s) { return s; } : decodeURIComponent; | |
var pairs = document.cookie.split('; '); | |
for(var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { | |
if(decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined | |
} | |
return null; | |
}; | |
})(jQuery); | |
jQuery.noConflict(); | |
j$ = jQuery; | |
var HOST = location.hostname; // アクセスURLホスト | |
var INTERVAL = 500; // | |
var d = document; | |
var $ = function(id) { return d.getElementById(id); }; | |
var $x = function(xp,dc) { return d.evaluate(xp, dc||d, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }; | |
var $a = function(xp,dc) { var r = d.evaluate(xp, dc||d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var a=[]; for(var i=0; i<r.snapshotLength; i++){ a.push(r.snapshotItem(i)); } return a; }; | |
var $e = function(e,t,f) { if (!e) return; e.addEventListener(t, f, false); }; | |
( function() { | |
console.log("*** bro3_duel ***"); | |
j$.get("http://"+HOST+"/card/duel_set.php",function(y){ | |
var htmldoc = document.createElement("html"); | |
htmldoc.innerHTML = y; | |
// 6枚目がセットされているか | |
if ( xpath('//ul[@class="deck_card"]/li[6]/dl/dd[3]/span[2]', htmldoc).snapshotItem(0).innerHTML.match("---/---") ) { | |
console.log("*** no deck set ***"); | |
} else { | |
j$.get("http://"+HOST+"/pvp_duel/select_enemy.php?deck=1",function(x){ | |
var htmldoc2 = document.createElement("html"); | |
htmldoc2.innerHTML = x; | |
try { | |
var rival_list = xpath('//ul[@class="rival_list"]/li/a[@class="thickbox btn_battle"]', htmldoc2); | |
j$.get( rival_list.snapshotItem(0).href, function(x){ | |
x.match(/battleStart\((\d+),\s(\d+),\s(\d+)\)/); | |
var c = {}; | |
c['deck'] = 1; | |
c['euid'] = parseInt(RegExp.$2); | |
c['edeck'] = 0; | |
// デュエルの開始 | |
j$.get("http://" + HOST + "/pvp_duel/process_json.php?deck=1&euid=" + c['euid'] + "&edeck=0", c , function(x) { | |
location.reload(); | |
}); | |
}); | |
} catch(e) { | |
console.log("*** no duel ***"); | |
} | |
}); | |
} | |
}); | |
})(); | |
// ================================================================================================================================================================================= | |
// サブルーチン | |
// ================================================================================================================================================================================= | |
function xpath(query,targetDoc) { | |
return document.evaluate(query, targetDoc, null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment