Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node version of Zinnsoldat #26

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env*
!.env.example
1 change: 1 addition & 0 deletions node/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 10 additions & 0 deletions node/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 1. öffne die Entwicklerwerkzeuge ([F12] oder [links click, Q])
# 2. führe folgenden Code aus: 'fetch("https://www.reddit.com/r/place/").then(res => res.text()).then(res => console.log(res.match(/"accessToken":"(\\"|[^"]*)"/)[1]));'
# 3. kopiere Zeichenkette (sowas wie "eyJhbGciOiJSUzI1NiIsImtpZCI6IlNIQTI1Nj...") in zs_accessToken
# WICHTIG: GIB NIEMANDEN DIESE ZEICHENKETTE, DIESER ERLAUBT ZUGRIFF AUF DEINEN ACCOUNT

# 1. open developer tools ([F12] or [left click, Q])
# 2. run following code: 'fetch("https://www.reddit.com/r/place/").then(res => res.text()).then(res => console.log(res.match(/"accessToken":"(\\"|[^"]*)"/)[1]));'
# 3. copy string (something like "eyJhbGciOiJSUzI1NiIsImtpZCI6IlNIQTI1Nj...") to zs_accessToken
# IMPORTANT: DONT GIVE THIS STRING TO ANYBODY, IT GIVES ACCESS TO YOUR ACCOUNT
ZN_TOKEN=***
16 changes: 16 additions & 0 deletions node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20.5.0-bullseye-slim

WORKDIR /app

COPY package-lock.json .
COPY package.json .
RUN npm install

COPY . .

# Modify the code to use the env var
RUN sed -i 's/const zs_accessToken = "";/const zs_accessToken = process.env.ZN_TOKEN;/g' index.js
RUN cat index.js
USER 1000:1000

ENTRYPOINT [ "node", "index.js" ]
30 changes: 30 additions & 0 deletions node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Der kopflose Zinnsoldat
Der kopflose Zinnsoldat übernimmt die selben Aufgaben wie der Zinnsoldat, braucht aber keinen offenen Browsertab.

## Benutzung
Es gibt zwei Möglichkeiten, den Zinnsoldaten zu verwenden:

### NodeJS + NPM
Für diese Installationsvariante benötigt man lediglich NodeJS und NPM.

Zuerst muss die `index.js`-Datei mit dem eigenen Account personalisiert werden, danach müssen folgende Kommandos ausgeführt werden:

```sh
npm install

# Einfach starten
node index.js

# Im Hintergrund ausführen
chmod +x ./start.sh
./start.sh
```

### Docker
Hierfür wird Docker + Docker-Compose oder vergleichbares benötigt.

Kopieren Sie zuerst die `.env.example`-Datei in eine `.env`-Datei, und personalisieren Sie diese. Führen Sie danach den folgenden Befehl aus:

```sh
docker compose up # [-d] für einen Hintergrundprozess
```
Empty file added node/all.log
Empty file.
6 changes: 6 additions & 0 deletions node/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'

services:
zinnsoldat:
build: .
env_file: .env
Loading