Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""One-time Tampermonkey storage reset + clean policy re-import on neko-3."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
PASS = "Xiao4669805"
|
|
|
|
CMD = r"""
|
|
set -e
|
|
name=douyinweb-neko-3
|
|
docker exec "$name" supervisorctl stop google-chrome
|
|
docker exec "$name" sh -c '
|
|
ext=dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
base=/home/neko/.config/chromium/Default
|
|
ts=$(date +%s)
|
|
for dir in "Local Extension Settings/$ext" "Managed Extension Settings/$ext" "Sync Extension Settings/$ext"; do
|
|
if [ -d "$base/$dir" ]; then
|
|
mv "$base/$dir" "$base/${dir}.bak-$ts"
|
|
echo "backed_up $dir"
|
|
fi
|
|
done
|
|
mkdir -p "$base/Local Extension Settings/$ext" "$base/Managed Extension Settings/$ext"
|
|
chmod -R u+rwX "$base/Local Extension Settings" "$base/Managed Extension Settings"
|
|
'
|
|
docker exec "$name" supervisorctl start google-chrome
|
|
sleep 12
|
|
docker exec "$name" python3 - <<'PY'
|
|
import json
|
|
import urllib.request
|
|
|
|
junk = ("tampermonkey.net/changelog", "tampermonkey.net/installed")
|
|
with urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=5) as resp:
|
|
tabs = json.loads(resp.read().decode())
|
|
closed = 0
|
|
for tab in tabs:
|
|
url = tab.get("url") or ""
|
|
if any(x in url for x in junk):
|
|
tid = tab.get("id")
|
|
if tid:
|
|
urllib.request.urlopen(f"http://127.0.0.1:9222/json/close/{tid}", timeout=3)
|
|
closed += 1
|
|
print("tabs", len(tabs), "closed_junk", closed)
|
|
for tab in tabs:
|
|
url = (tab.get("url") or "")[:100]
|
|
if "tampermonkey" in url or "studio.youtube" in url or "chrome-extension://dhdg" in url:
|
|
print("tab", url)
|
|
PY
|
|
docker exec "$name" sh -c 'grep -R -a "YouTube Studio Auto Dismiss" "/home/neko/.config/chromium/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo" 2>/dev/null | wc -c'
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
|
_i, o, e = c.exec_command(CMD, timeout=180)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("ERR", err[:2000])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|