72 lines
2.9 KiB
Python
72 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
CMD = r"""
|
|
echo 4669805 | sudo -S -p '' bash -lc '
|
|
EXT=dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
echo --- profile8 ---
|
|
P8=/opt/douyinWEB/backend/data/neko/profiles/8/Default/Local\ Extension\ Settings/$EXT
|
|
ls -la "$P8" | head
|
|
grep -aR "YouTube Studio Auto Dismiss" "$P8" | wc -l
|
|
grep -ao "YouTube Studio Auto Dismiss" "$P8"/* 2>/dev/null | head
|
|
echo --- seed ---
|
|
SEED=/opt/douyinWEB/backend/neko/tampermonkey-seed/Default/Local\ Extension\ Settings/$EXT
|
|
ls -la "$SEED" | head
|
|
grep -aR "YouTube Studio Auto Dismiss" "$SEED" | wc -l
|
|
# Try installAsSystemScripts true and reimport
|
|
python3 - <<'"'"'PY'"'"'
|
|
import json
|
|
from pathlib import Path
|
|
p=Path("/opt/douyinWEB/backend/neko/policies/policies.json")
|
|
d=json.loads(p.read_text())
|
|
ji=d["3rdparty"]["extensions"]["dhdgffkkebhmkfjojejmpbldmpobfkfo"]["jsonImport"][0]
|
|
ji["installAsSystemScripts"]=True
|
|
p.write_text(json.dumps(d,ensure_ascii=False,indent=2)+"\n")
|
|
print("set installAsSystemScripts", ji)
|
|
PY
|
|
for i in 1 2; do
|
|
name=douyinweb-ops-neko-$i
|
|
docker exec "$name" supervisorctl stop google-chrome || true
|
|
sleep 1
|
|
# clone profile8 LES if it has script
|
|
if grep -aq "YouTube Studio Auto Dismiss" $P8/* 2>/dev/null; then
|
|
echo cloning_from_profile8_to_ops$i
|
|
docker exec "$name" bash -lc "rm -rf /home/neko/.config/google-chrome/Default/Local\ Extension\ Settings/$EXT /home/neko/.config/google-chrome/Default/Managed\ Extension\ Settings/$EXT"
|
|
docker cp "$P8" "$name:/home/neko/.config/google-chrome/Default/Local Extension Settings/$EXT"
|
|
docker exec "$name" bash -lc "rm -f /home/neko/.config/google-chrome/Default/Local\ Extension\ Settings/$EXT/LOCK; chown -R neko:neko /home/neko/.config/google-chrome/Default/Local\ Extension\ Settings/$EXT"
|
|
else
|
|
echo profile8_empty_try_system_import
|
|
docker exec "$name" bash -lc "rm -rf /home/neko/.config/google-chrome/Default/Local\ Extension\ Settings/$EXT /home/neko/.config/google-chrome/Default/Managed\ Extension\ Settings/$EXT"
|
|
fi
|
|
docker exec "$name" supervisorctl start google-chrome
|
|
done
|
|
sleep 20
|
|
for i in 1 2; do
|
|
echo ===== OPS$i =====
|
|
docker exec douyinweb-ops-neko-$i bash -lc "
|
|
P=/home/neko/.config/google-chrome/Default
|
|
du -sh \"\$P/Local Extension Settings/$EXT\" 2>/dev/null
|
|
echo HITS=\$(grep -aR \"YouTube Studio Auto Dismiss\" \"\$P/Local Extension Settings/$EXT\" 2>/dev/null | wc -l)
|
|
strings \"\$P/Local Extension Settings/$EXT\"/* 2>/dev/null | grep -E \"2\\.2\\.|Auto Dismiss\" | head -8
|
|
"
|
|
done
|
|
'
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
_i, o, e = c.exec_command(CMD, timeout=180)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|