Commit ad7a99f3 by yexing

[yx] update

parents
node_modules
.vscode
pnpm-lock.yaml
tmp
test
__pycache__
[paths]
download_path =
tmp_path =
[chromium_options]
address = 127.0.0.1:9222
browser_path = chrome
arguments = ['--no-default-browser-check', '--disable-suggestions-ui', '--no-first-run', '--disable-infobars', '--disable-popup-blocking', '--hide-crash-restore-bubble', '--disable-features=PrivacySandboxSettings4']
extensions = []
prefs = {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}}
flags = {}
load_mode = normal
user = Default
auto_port = False
system_user_path = False
existing_only = False
new_env = False
[session_options]
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'connection': 'keep-alive', 'accept-charset': 'GB2312,utf-8;q=0.7,*;q=0.7'}
[timeouts]
base = 10
page_load = 30
script = 30
[proxies]
http =
https =
[others]
retry_times = 3
retry_interval = 2
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default;
const template = require("@babel/template").default;
const generator = require("@babel/generator");
const t = require("@babel/types");
const fs = require("fs");
const jsCode = fs.readFileSync("./src/protobufjs.js", { encoding: "utf8" });
const ast = parser.parse(jsCode);
let proto = [`syntax = "proto3";`, ''];
const check = (path, options) => {
let name, type, value = path.node.test?.value || 1;
let { seq = path.node.consequent } = options || {};
const seq0 = seq[0] || seq;
let exp = seq0?.expression;
if (t.isAssignmentExpression(exp)) {
name = exp.left.property?.name;
const callee = exp.right.callee;
type = callee.property.name;
type = type == 'decode' ? callee.object.property.name : type;
} else if (t.isSequenceExpression(exp)) {
name = exp.expressions[1].callee.object.property.name;
const callee = exp.expressions[1].arguments[0].callee;
// decode | string
type = callee.object.property?.name || callee.property.name;
type = `repeated ${type}`;
} else if (t.isIfStatement(seq0)) {
// int64
exp = seq0.alternate.expression;
name = exp.callee.object.property.name;
type = exp.arguments[0].callee.property.name;
type = `repeated ${type}`;
} else if (t.isForStatement(seq[2])) {
const cases = seq[2].body.body.at(-1).cases;
const [k, v] = [cases[0], cases[1]].map(
x => {
const callee = x.consequent[0].expression.right.callee;
return callee.object.property?.name || callee.property.name;
}
);
type = `map<${k}, ${v}>`;
name = exp.left.left.property.name;
}
if (!(name && type && value)) return;
// console.log(path.toString());
proto.push(`\t${type} ${name} = ${value};`);
}
traverse(ast, {
AssignmentExpression(path) {
const left = path.node.left;
if (!(left?.property?.name === 'decode' && left.object.name === 'e')) return;
let flag = false;
path.traverse({
ForStatement(path) {
const message = path.node.init.declarations?.at(-1).init.callee?.property.name;
if (!message) return;
proto.push(`message ${message} {`);
flag = !flag;
console.log(path.toString());
let seq = path.node.body.body[1].consequent;
seq = seq?.body || seq;
if (!seq) return;
check(path, { seq });
},
SwitchCase(path) {
check(path);
}
});
if (flag) proto.push('}');
}
})
fs.writeFileSync("./proto/decode.proto", proto.join('\r\n'));
This source diff could not be displayed because it is too large. You can view the blob instead.
javascript:(
function(){
const oInput = document.createElement('input');
const json = {}
document.cookie.split(';').forEach(x => {
const [k, v] = x.trim().split('=');
json[k] = v;
});
oInput.value = JSON.stringify(json);
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
oInput.remove();
alert('复制成功');
}
)();
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"dependencies": {
"@babel/generator": "^7.26.9",
"@babel/parser": "^7.26.9",
"@babel/template": "^7.26.9",
"@babel/traverse": "^7.26.9",
"@babel/types": "^7.26.9"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
from pathlib import Path
from DrissionPage import Chromium, ChromiumOptions
from DrissionPage.items import WebPageTab
from DrissionPage.common import Settings
from tool.io import w2json
Settings.set_raise_when_wait_failed(False)
class launcher:
def __init__(self, email: str, password: str):
self._email = email
self._password = password
self.driver = Chromium(ChromiumOptions().headless())
self.tab: WebPageTab = self.driver.latest_tab
self.tp = Path('./tmp')
def login(self):
self.tab.get("https://fxg.jinritemai.com/login/common")
if (not self.tab.wait.url_change("login", exclude=True, timeout=120)):
self.tab.ele('@text()=邮箱登录').click()
self.tab.ele('@placeholder=请输入邮箱').input(self._email)
self.tab.ele('@placeholder=密码').input(self._password)
self.tab.run_js('document.querySelector(".auxo-checkbox").click()', as_expr=True)
self.tab.run_js('document.querySelector("button").click()', as_expr=True)
if self.tab.wait.ele_displayed("#fxg-pc-header"):
self.tab.run_js('document.querySelector(".ecom-menu-badge").click()', as_expr=True)
self.tab = self.driver.latest_tab
cookie = self.tab.cookies().as_dict()
shop_id = cookie["SHOP_ID"] # ecom_gray_shop_id
w2json(self.tp / 'cookie' / f'{shop_id}.json', cookie)
def main():
pass
if __name__ == '__main__':
main()
from dataclasses import dataclass, fields
from typing import List
@dataclass
class Conversation:
con_id: str # 会话ID
con_short_id: str # 会话短ID
sub_con_short_id: str = None # 子会话短ID
ticket: str = None # 标签
def __post_init__(self):
self.shop_id, self.receiver_id = self.con_id.split(':', 2)[:2] # 商店ID, 顾客ID
def set_ctx(self, other) -> None:
for x in fields(self): setattr(other, x.name, getattr(self, x.name))
@dataclass
class Receiver:
nickname: str # 昵称
avatar_uri: str # 头像
messages: List[str] = [] # 消息列表
@dataclass
class EventState:
chat: bool = False # 准备对话
notify: bool = False # 处理新信息
active_chat: bool = False # 主动对话
refresh_msg: bool = False # 刷新信息
This diff is collapsed. Click to expand it.
import json
import sys
from pathlib import Path
from loguru import logger
from typing import Any, List
def endir(fp, limit: int = 2):
x = fp
tm: List[Path] = []
for _ in range(limit):
fr = Path(x).parent
tm.append(fr)
x = fr
for fr in reversed(tm):
if not fr.exists(): fr.mkdir()
return fp
def w2json(fp: str, data: Any):
with open(endir(fp), 'w', encoding='utf8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
def r2json(fp: str):
with open(endir(fp), 'r', encoding='utf8') as f:
return json.load(f)
def init_logger(log_path: str):
logger.remove()
logger.add(sys.stdout, level="INFO")
logger.add(
endir(log_path),
level="DEBUG",
backtrace=True,
diagnose=True
)
import time
import base64
import hashlib
USEC = 10 ** 6
def get_ts(unit: int = 3) -> int:
return int(time.time() * 10 ** unit) # 13
def get_ws_key() -> str:
return base64.b64encode(hashlib.md5(str(get_ts()).encode()).digest()).decode()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment