Last active
April 17, 2019 14:16
-
-
Save hot-2130/ecc2cb8cbcf3e1ceed2bef368284e231 to your computer and use it in GitHub Desktop.
ブラウザ三国志 トレード1ページ入札(即札以外)
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 bro3_trade_pagebulk | |
| // @namespace bro3_trade_pagebulk | |
| // @description ブラウザ三国志 トレード1ページ入札 byほっと | |
| // @include https://*.3gokushi.jp/card/trade.php* | |
| // @include http://*.3gokushi.jp/card/trade.php* | |
| // @version 1.2 | |
| // @require https://code.jquery.com/jquery-2.1.4.min.js | |
| // @require https://code.jquery.com/ui/1.11.4/jquery-ui.min.js | |
| // @resource jqueryui_css http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css | |
| // ==/UserScript== | |
| // version date author | |
| // 1.1 2019/04/14 作成開始 | |
| // 1.2 2019/04/17 バグ修正 | |
| // to do | |
| // 1ページに表示されているカードを上から順に入札していく(即札以外) | |
| // load jQuery | |
| jQuery.noConflict(); | |
| j$ = jQuery; | |
| //----------// | |
| // 変数定義 // | |
| //----------// | |
| // ソフトウェアバージョン | |
| var VERSION = "1.1"; | |
| var SERVER_NAME = location.hostname.match(/^(.*)\.3gokushi/)[1]; | |
| // 特殊定数 | |
| var PROTOCOL = location.protocol; | |
| var HOST = location.hostname; // アクセスURLホスト | |
| var SERVICE = ''; // サービス判定が必要な場合に使用する予約定数 | |
| var SVNAME = HOST.substr(0,location.hostname.indexOf(".")) + SERVICE; | |
| var SERVER_SCHEME = location.protocol + "//"; | |
| var BASE_URL = SERVER_SCHEME + location.hostname; | |
| // 固定設定 | |
| var TPB_MAXNUM = 20; //入札上限 | |
| var TPB_INTERVAL = 500; // (ms) | |
| //---------------------- | |
| // メインルーチン | |
| //---------------------- | |
| (function() { | |
| // ボタンを設置 | |
| j$(".freeword").append( | |
| "<li'>" + | |
| "<span>" + | |
| "<input type='text' id='tpb_text' size='10' style='margin-left: 10px;' ></input>" + | |
| "<input type='button' id='tpb_btn' value='ページ一括入札'></input>" + | |
| "</span>" + | |
| "</li>" | |
| ); | |
| //--------------------- | |
| // 入札ボタン | |
| //--------------------- | |
| j$("#tpb_btn").click( | |
| function() { | |
| if (isInteger(Number(j$("#tpb_text").val()))){ | |
| if (Number(j$("#tpb_text").val())<10){ | |
| alert("10以上の整数を入力してください"); | |
| return; | |
| } | |
| tpb_trade_buy(); | |
| } else { | |
| alert("整数を入力してください"); | |
| return; | |
| } | |
| } | |
| ); | |
| })(); | |
| //--------------------- | |
| // 入札する | |
| //--------------------- | |
| function tpb_trade_buy(){ | |
| var str_text=j$("div[class^='right-box']").text(); | |
| var l_match = str_text.match(/持てる武将カード残り(\d+)枚/); | |
| var l_busyo = Number(l_match[1]); | |
| l_match = str_text.match(/入札:(\d+)件/); | |
| var l_nyu = TPB_MAXNUM-Number(l_match[1]); | |
| var l_num=0; | |
| var l_limitnum=TPB_MAXNUM; | |
| var l_buynum=0; | |
| //TP | |
| str_text=j$("div[id='status_point']").text(); | |
| l_match = str_text.match(/(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/); | |
| var l_tp=Number(l_match[3]); | |
| if (l_busyo<l_limitnum){ | |
| l_limitnum=l_busyo; | |
| } | |
| if (l_nyu<l_limitnum){ | |
| l_limitnum=l_nyu; | |
| } | |
| var array = []; | |
| var l_limitprice=Number(j$("#tpb_text").val()); | |
| j$("#tpb_btn").off('click'); | |
| j$("table[class='tradeTables'] td[class='trade']").each(function(index){ | |
| l_num=l_num+1; | |
| var l_check=j$("a", this).eq(0).attr('href'); | |
| if (l_check==null){ | |
| //TP不足・カード上限 | |
| return 0; | |
| } else { | |
| if (l_buynum<l_limitnum){ | |
| l_match = j$("a", this).eq(0).attr('href').match(/trade_bid.php\?id=(\d+)&t=([^&]*)&k=([^&]*)&p=([^&]*)&s=([^&]*)&o=(.*)/); | |
| if (l_match.length==7){ | |
| var l_timelimit=j$("table[class='tradeTables'] tr:eq("+l_num+") td[class='limit']").eq(0).text(); | |
| var l_price=j$("table[class='tradeTables'] tr:eq("+l_num+") td:eq(7) strong").eq(0).text(); | |
| if (l_price<=l_limitprice){ | |
| var ary1 = {}; | |
| var l_flag=0; | |
| ary1.id = l_match[1]; | |
| //ary1.t = l_match[2]; | |
| //ary1.k = l_match[3]; | |
| //ary1.p = l_match[4]; | |
| //ary1.s = l_match[5]; | |
| //ary1.o = l_match[6]; | |
| ary1.price = l_limitprice; | |
| //TPチェック | |
| if (((array.length+1)*l_limitprice)<=l_tp){ | |
| if (l_timelimit=="---"){ | |
| ary1.buy = '落札する' | |
| //l_flag=1; | |
| } else { | |
| //24時間以内かどうか | |
| var l_dt = new Date(j$("#server_time").text()); | |
| var l_ldt = new Date(l_timelimit.substr(0,10) + " " + l_timelimit.substr(10)); | |
| var l_resttime = (l_ldt.getTime() - l_dt.getTime()) / 1000; | |
| if (l_resttime < 86400) { | |
| ary1.buy = '入札する' | |
| l_flag=1; | |
| } | |
| } | |
| if (l_flag==1){ | |
| array.push(ary1) ; | |
| l_buynum=l_buynum+1; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| var l_wait = false; | |
| var l_count = 0; | |
| var l_url= BASE_URL + '/card/trade_bid.php'; | |
| var l_ssid = tpb_getSessionId(); | |
| if (array.length>0){ | |
| var timer1 = setInterval(function() { | |
| if (l_wait) { | |
| return; | |
| } | |
| l_wait = true; | |
| j$("#tpb_btn").val("処理中 (" + (l_count+1) + "/" + array.length + ")"); | |
| // 送信データの作成 | |
| var params = new Object; | |
| params['ssid'] = l_ssid; | |
| params['exhibit_id'] = array[l_count].id; | |
| params['exhibit_price'] = array[l_count].price; | |
| params['bid_btn'] = array[l_count].buy; | |
| j$.ajax({ | |
| url: l_url, | |
| type: 'post', | |
| datatype: 'html', | |
| cache: false, | |
| data: params | |
| }).done(function(res){ | |
| l_count++; | |
| console.log(l_count); | |
| if (l_count >= array.length) { | |
| location.reload(); | |
| clearInterval(timer1); | |
| } | |
| l_wait = false; | |
| }); | |
| }, TPB_INTERVAL); | |
| } | |
| } | |
| //------------------// | |
| // 整数チェック // | |
| //------------------// | |
| function isInteger(x) { | |
| return Math.round(x) === x; | |
| } | |
| //------------------// | |
| // セッションID取得 // | |
| //------------------// | |
| function tpb_getSessionId() { | |
| return tpb_getCookie('SSID'); | |
| } | |
| function tpb_getCookie(name) { | |
| var nameEQ = name + "="; | |
| var ca = document.cookie.split(';'); | |
| for(var i=0;i < ca.length;i++) { | |
| var c = ca[i]; | |
| while (c.charAt(0)==' ') c = c.substring(1,c.length); | |
| if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); | |
| } | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment