-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Contributor: | ||
# fffonion <[email protected]> | ||
import os | ||
import re | ||
import sys | ||
import time | ||
import base64 | ||
|
@@ -148,7 +149,21 @@ def decrypt_file(self, filein, fileout, ext = 'png'): | |
pass | ||
|
||
#ht = httplib2.Http(timeout = 15,proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL, "192.168.124.1", 23300)) | ||
|
||
def htmlescape(htmlstr): | ||
def replc(match): | ||
# self._print match.group(0),match.group(1),match.group(2) | ||
dict = {'amp':'&', 'nbsp':' ', 'quot':'"', 'lt':'<', 'gt':'>', 'copy':'©', 'reg':'®'} | ||
# dict+={'∀':'forall','∂':'part','∃':'exist','∅':'empty','∇':'nabla','∈':'isin','∉':'notin','∋':'ni','∏':'prod','∑':'sum','−':'minus','∗':'lowast','√':'radic','∝':'prop','∞':'infin','∠':'ang','∧':'and','∨':'or','∩':'cap','∪':'cup','∫':'int','∴':'there4','∼':'sim','≅':'cong','≈':'asymp','≠':'ne','≡':'equiv','≤':'le','≥':'ge','⊂':'sub','⊃':'sup','⊄':'nsub','⊆':'sube','⊇':'supe','⊕':'oplus','⊗':'otimes','⊥':'perp','⋅':'sdot','Α':'Alpha','Β':'Beta','Γ':'Gamma','Δ':'Delta','Ε':'Epsilon','Ζ':'Zeta','Η':'Eta','Θ':'Theta','Ι':'Iota','Κ':'Kappa','Λ':'Lambda','Μ':'Mu','Ν':'Nu','Ξ':'Xi','Ο':'Omicron','Π':'Pi','Ρ':'Rho','Σ':'Sigma','Τ':'Tau','Υ':'Upsilon','Φ':'Phi','Χ':'Chi','Ψ':'Psi','Ω':'Omega','α':'alpha','β':'beta','γ':'gamma','δ':'delta','ε':'epsilon','ζ':'zeta','η':'eta','θ':'theta','ι':'iota','κ':'kappa','λ':'lambda','μ':'mu','ν':'nu','ξ':'xi','ο':'omicron','π':'pi','ρ':'rho','ς':'sigmaf','σ':'sigma','τ':'tau','υ':'upsilon','φ':'phi','χ':'chi','ψ':'psi','ω':'omega','ϑ':'thetasym','ϒ':'upsih','ϖ':'piv','Œ':'OElig','œ':'oelig','Š':'Scaron','š':'scaron','Ÿ':'Yuml','ƒ':'fnof','ˆ':'circ','˜':'tilde',' ':'ensp',' ':'emsp',' ':'thinsp','':'zwnj','':'zwj','':'lrm','':'rlm','–':'ndash','—':'mdash','‘':'lsquo','’':'rsquo','‚':'sbquo','“':'ldquo','”':'rdquo','„':'bdquo','†':'dagger','‡':'Dagger','•':'bull','…':'hellip','‰':'permil','′':'prime','″':'Prime','‹':'lsaquo','›':'rsaquo','‾':'oline','€':'euro','™':'trade','←':'larr','↑':'uarr','→':'rarr','↓':'darr','↔':'harr','↵':'crarr','⌈':'lceil','⌉':'rceil','⌊':'lfloor','⌋':'rfloor','◊':'loz','♠':'spades','♣':'clubs','♥':'hearts','♦':'diams'} | ||
if match.groups > 2: | ||
if match.group(1) == '#': | ||
if match.group(2).startswith('x'):#xD, xA | ||
return unichr(int(match.group(2)[1:],16)) | ||
else: | ||
return unichr(int(match.group(2))) | ||
else: | ||
return dict.get(match.group(2), '?') | ||
htmlre = re.compile("&(#?)(\d{1,5}|\w{1,8}|[a-z]+);") | ||
return htmlre.sub(replc, htmlstr) | ||
|
||
class poster(): | ||
def __init__(self, loc, logger, ua): | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# coding:utf-8 | ||
from _prototype import plugin_prototype | ||
import sys | ||
import os | ||
import re | ||
from cross_platform import * | ||
from xml2dict import XML2Dict | ||
# start meta | ||
__plugin_name__ = 'scratch carddeck from REAL client' | ||
__author = 'fffonion' | ||
__version__ = 0.2 | ||
hooks = {} | ||
extra_cmd = {'scratch_carddeck':'scratch_carddeck', 'scc':'scratch_carddeck','check_debug':'check_debug','cd':'check_debug', | ||
'read_decks':'read_decks','rd':'read_decks'} | ||
# end meta | ||
def tolist(obj): | ||
if not isinstance(obj, list): | ||
return [obj] | ||
else: | ||
return obj | ||
|
||
def iter_printer(l, sep = '\n'): | ||
cnt = 1 | ||
str = '' | ||
for e in l: | ||
str += '%d.%-10s%s' % (cnt, e.strip('\n'), (cnt % 3 and '' or sep)) | ||
cnt += 1 | ||
return str.decode('utf-8') | ||
|
||
def read_decks(plugin_vals): | ||
def do(*args): | ||
get=lambda x:XML2Dict().fromstring(x).response.body.roundtable_edit.deck_cards | ||
poster=plugin_vals['poster'] | ||
pcard=plugin_vals['player'].card | ||
cf=plugin_vals['cf'] | ||
list_option=cf.options | ||
for i in range(1,4,1): | ||
print(du8('卡组%d:'%i)) | ||
C=get(poster.post('roundtable/edit', postdata = 'move=1%s'%(i>1 and '&deck_id=%s'%i or ''))[1]).rstrip(',empty').split(',') | ||
CL=tolist(C) | ||
print(du8('\n'.join(['|'.join(map( | ||
lambda x:' %-12s' % pcard.db[pcard.sid(x).master_card_id][0], | ||
C[i:min(i + 3, len(CL))] | ||
)) for i in range(0, len(CL), 3)]))) | ||
decks = list_option('carddeck') | ||
print(du8('\n选择卡组,输入卡组名以添加新卡组,按回车跳过')) | ||
print(iter_printer(decks)) | ||
inp = raw_input("> ") | ||
if inp == "": | ||
continue | ||
elif inp in [str(i) for i in range(1, len(decks) + 1)]: | ||
name = decks[int(inp) - 1] | ||
else: | ||
name = inp | ||
write_config('carddeck', name, C) | ||
print(du8('保存到了%s' % name)) | ||
#poster.post('roundtable/edit', postdata = 'move=1&deck_id=1') | ||
return do | ||
|
||
def scratch_carddeck(plugin_vals): | ||
def do(*args): | ||
cf=plugin_vals['cf'] | ||
list_option=cf.options | ||
def write_config(sec, key, val): | ||
if not cf.has_section(sec): | ||
cf.add_section(sec) | ||
cf.set(sec, key, val) | ||
f = open(plugin_vals['configfile'], "w") | ||
cf.write(f) | ||
f.flush() | ||
print(du8('注意:你必须使用修改版的odex文件才能截获卡组信息!\n你可以输入check_debug或cd来检查修改是否生效。\n你也可以使用更简单的read_decks来读取卡组')) | ||
#check adb existence, wait for device | ||
print(du8('=======请将手机连接电脑,别忘了打开USB调试,关闭电脑上的各种助手和豆荚')) | ||
if os.system('adb wait-for-device')==1: | ||
print(du8('未能运行adb,请去谷歌/度娘下载之-w-')) | ||
return False | ||
#clear buffer | ||
os.system('adb logcat -c') | ||
#suppress all but D/CJH | ||
#btw CJH is...what? | ||
logcat=os.popen('adb logcat CJH:D *:S') | ||
print(du8('=======Good!')) | ||
print(du8('请设置一次卡组,并保存\n你可以按Ctrl+C退出')) | ||
while(1): | ||
try: | ||
line=logcat.readline() | ||
C=re.findall('([\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,' | ||
'[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+)',line) | ||
if C!=[]: | ||
decks = list_option('carddeck') | ||
print(du8('\n选择卡组,输入卡组名以添加新卡组')) | ||
print(iter_printer(decks)) | ||
inp = raw_input("> ") | ||
if inp == "": | ||
continue | ||
elif inp in [str(i) for i in range(1, len(decks) + 1)]: | ||
name = decks[int(inp) - 1] | ||
else: | ||
name = inp | ||
write_config('carddeck', name, C[0].rstrip(',empty')) | ||
print(du8('保存到了%s' % name)) | ||
else: | ||
continue | ||
except KeyboardInterrupt: | ||
break | ||
print(du8('请设置一次卡组,并保存\n你可以按Ctrl+C退出')) | ||
|
||
return do | ||
|
||
def check_debug(plugin_vals): | ||
def do(*args): | ||
print(du8('等待设备连接')) | ||
os.system('adb wait-for-device') | ||
os.system('adb logcat -c') | ||
print(du8('请在游戏中随意执行一个操作。\n如果一直未能显示测试通过,请到这里查看详细帮助\nhttps://github.com/fffonion/MAClient/wiki/carddeck_edit')) | ||
logcat=os.popen('adb logcat CJH:D *:S') | ||
while(1): | ||
try: | ||
line=logcat.readline() | ||
except KeyboardInterrupt: | ||
break | ||
if line.startswith('D/CJH'): | ||
print(du8('测试通过!现在你可以输入scratch_carddeck或scc来抓取卡组了\n请按Ctrl+C退出')) | ||
return | ||
return do |
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
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