Skip to content

Commit 80942fa

Browse files
committed
Squashed commits
0 parents  commit 80942fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+8101
-0
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and Document Userscripts
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Build, Document, and Deploy
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v5
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v5
16+
with:
17+
node-version: "lts/*"
18+
19+
- name: Generate All Files
20+
run: bash build.sh ${{ github.repository }}
21+
22+
- name: Commit Generated Files
23+
uses: stefanzweifel/git-auto-commit-action@v6
24+
with:
25+
commit_message: 'build: auto-generate dist, meta, docs and readme'
26+
file_pattern: 'userscripts/dist/*.user.js userscripts/meta/*.meta.js userscripts/docs/*.md README.md'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Delete Old Workflow Runs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
retain_days:
7+
description: 'Days-worth of runs to keep for each workflow'
8+
required: true
9+
default: '2'
10+
keep_minimum_runs:
11+
description: 'Minimum runs to keep for each workflow'
12+
required: true
13+
default: '5'
14+
schedule:
15+
- cron: '0 2 * * 0'
16+
17+
jobs:
18+
build:
19+
name: Delete Old Workflow Runs
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Delete Old Workflow Runs
23+
uses: Mattraks/delete-workflow-runs@v2
24+
with:
25+
retain_days: ${{ github.event.inputs.retain_days }}
26+
keep_minimum_runs: ${{ github.event.inputs.keep_minimum_runs }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Squash Commits
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
commit_message:
7+
description: 'The commit message for the new, single commit'
8+
required: true
9+
default: 'Squashed commits'
10+
branch:
11+
description: 'The branch to squash'
12+
required: true
13+
default: 'main'
14+
15+
jobs:
16+
squash:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v5
21+
with:
22+
ref: ${{ github.event.inputs.branch }}
23+
24+
- name: Configure Git
25+
run: |
26+
git config --global user.name 'GitHub Actions'
27+
git config --global user.email 'actions@github.com'
28+
29+
- name: Add files to orphan branch and replace target branch
30+
run: |
31+
git checkout --orphan squash-commits-tmp
32+
git add -A
33+
git commit -m "${{ github.event.inputs.commit_message }}"
34+
git branch -D ${{ github.event.inputs.branch }}
35+
git branch -m ${{ github.event.inputs.branch }}
36+
37+
- name: Force push to the branch
38+
run: git push -f origin ${{ github.event.inputs.branch }}

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Trakt.tv Userscript Collection
2+
An extensive userscript collection for trakt.tv. Please report any bugs you encounter, if you don't then probably no one else will. Feature requests and (good) ideas for more userscripts are always welcome.
3+
4+
[![github stars](https://img.shields.io/github/stars/Fenn3c401/Trakt.tv-Userscript-Collection?style=flat&color=e3b341)](../../stargazers) [![open issues](https://img.shields.io/github/issues/Fenn3c401/Trakt.tv-Userscript-Collection?color=3fb950)](../../issues) [![closed issues](https://img.shields.io/github/issues-closed/Fenn3c401/Trakt.tv-Userscript-Collection?color=ab7df8)](../../issues?q=is%3Aissue%20state%3Aclosed) [![last commit](https://img.shields.io/github/last-commit/Fenn3c401/Trakt.tv-Userscript-Collection?color=blue)](../../commits) [![userscripts](https://img.shields.io/badge/userscripts-12-a55428)](#userscripts) [![lines of code](https://img.shields.io/badge/loc-2409-orange)](#userscripts)
5+
6+
## Userscripts
7+
| *NAME* | *VERSION* | *LOC* | *INSTALL* |
8+
|:---|:---|:---|:---|
9+
| [Custom Element Hider](userscripts/docs/rg49pj29.md) | `1.0.2` | `15` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/rg49pj29.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/rg49pj29.min.user.js) |
10+
| [Trakt.tv \| Actor Pronunciation Helper](userscripts/docs/71cd9s61.md) | `0.4.2` | `102` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/71cd9s61.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/71cd9s61.min.user.js) |
11+
| [Trakt.tv \| Average Season And Episode Ratings](userscripts/docs/yl9xlca7.md) | `1.0.2` | `94` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/yl9xlca7.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/yl9xlca7.min.user.js) |
12+
| [Trakt.tv \| Charts - Ratings Distribution](userscripts/docs/pmdf6nr9.md) | `1.0.2` | `219` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/pmdf6nr9.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/pmdf6nr9.min.user.js) |
13+
| [Trakt.tv \| Charts - Seasons](userscripts/docs/cs1u5z40.md) | `0.1.1` | `344` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/cs1u5z40.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/cs1u5z40.min.user.js) |
14+
| [Trakt.tv \| Consolidated Lists View](userscripts/docs/p2o98x5r.md) | `1.0.1` | `114` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/p2o98x5r.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/p2o98x5r.min.user.js) |
15+
| [Trakt.tv \| Custom Links (Watch-Now + External)](userscripts/docs/wkt34fcz.md) | `0.5.1` | `404` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/wkt34fcz.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/wkt34fcz.min.user.js) |
16+
| [Trakt.tv \| Enhanced List Preview Posters](userscripts/docs/kji85iek.md) | `1.0.0` | `42` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/kji85iek.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/kji85iek.min.user.js) |
17+
| [Trakt.tv \| Enhanced Title Metadata](userscripts/docs/fyk2l3vj.md) | `0.8.2` | `315` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/fyk2l3vj.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/fyk2l3vj.min.user.js) |
18+
| [Trakt.tv \| Nested Header Navigation Menus](userscripts/docs/txw82860.md) | `1.0.2` | `681` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/txw82860.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/txw82860.min.user.js) |
19+
| [Trakt.tv \| Scheduled E-Mail Data Exports](userscripts/docs/2hc6zfyy.md) | `1.0.1` | `53` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/2hc6zfyy.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/2hc6zfyy.min.user.js) |
20+
| [Trakt.tv \| Unlocked Client-Side VIP Features](userscripts/docs/x70tru7b.md) | `1.0.0` | `26` | [Standard](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/x70tru7b.user.js) / [Minified](https://raw.githubusercontent.com/Fenn3c401/Trakt.tv-Userscript-Collection/main/userscripts/dist/x70tru7b.min.user.js) |
21+
22+
## Requirements
23+
- [Tampermonkey](https://www.tampermonkey.net) as userscript manager. Use the beta version if you can.
24+
- Any Chromium/Gecko-based browser. For mobile devices I recommend the Android version of Firefox which allows for installing arbitrary extensions, including Tampermonkey.

build.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# --- CONFIGURATION ---
5+
REPO_SLUG=$1
6+
if [[ -z "$REPO_SLUG" ]]; then
7+
printf "Error: Repository slug not provided. Exiting.\n" >&2; exit 1
8+
fi
9+
BASE_URL="https://github.com/$REPO_SLUG"
10+
BASE_URL_RAW="https://raw.githubusercontent.com/$REPO_SLUG/main"
11+
12+
SRC_DIR='userscripts/src'
13+
META_DIR='userscripts/meta'
14+
DIST_DIR='userscripts/dist'
15+
DOCS_DIR='userscripts/docs'
16+
SCREENSHOTS_DIR='userscripts/docs/screenshots'
17+
18+
# --- SETUP ---
19+
printf "Initializing build environment...\n"
20+
npm install --save-dev esbuild cloc > /dev/null
21+
22+
printf "Removing old build artifacts...\n"
23+
mkdir -p "$META_DIR" "$DIST_DIR" "$DOCS_DIR" "$SCREENSHOTS_DIR"
24+
find "$META_DIR" "$DIST_DIR" "$DOCS_DIR" -maxdepth 1 -type f -delete
25+
26+
# --- README PREPARATION ---
27+
printf "Preparing README.md for update...\n"
28+
BEFORE_TABLE_FILE=$(mktemp)
29+
AFTER_TABLE_FILE=$(mktemp)
30+
TABLE_CONTENT_FILE=$(mktemp)
31+
32+
start_line=$(grep -n -m 1 '## Userscripts' README.md | cut -d: -f1)
33+
head -n "$start_line" README.md > "$BEFORE_TABLE_FILE"
34+
35+
end_line=$(tail -n +$((start_line + 1)) README.md | grep -n -m 1 -v '^|' | cut -d: -f1)
36+
if [[ -n "$end_line" ]]; then
37+
tail -n +$((start_line + end_line)) README.md > "$AFTER_TABLE_FILE"
38+
fi
39+
40+
printf "| *NAME* | *VERSION* | *LOC* | *INSTALL* |\n" > "$TABLE_CONTENT_FILE"
41+
printf "|:---|:---|:---|:---|\n" >> "$TABLE_CONTENT_FILE"
42+
43+
# --- MAIN PROCESSING LOOP ---
44+
printf "Starting to process userscripts in '%s'...\n" "$SRC_DIR"
45+
loc_count_total=0
46+
for file in "$SRC_DIR"/*.user.js; do
47+
id="$(basename "$file" .user.js)"
48+
printf ">> Processing ID: %s\n" "$id"
49+
50+
# --- 1. PARSE SOURCE FILE ---
51+
clean_content="$(tr -d '\r' < "$file")"
52+
script_name="$(grep -m 1 '// @name' <<< "$clean_content" | sed -E 's|// @name\s+||')"
53+
script_desc="$(grep -m 1 '// @description' <<< "$clean_content" | sed -E 's|// @description\s+||')"
54+
script_version="$(grep -m 1 '// @version' <<< "$clean_content" | sed -E 's|// @version\s+||')"
55+
script_namespace="$(grep -m 1 '// @namespace' <<< "$clean_content" | sed -E 's|// @namespace\s+||')"
56+
header="$(sed -n '\|^// ==UserScript==$|,\|^// ==/UserScript==$|p' <<< "$clean_content")"
57+
readme_comment="$(sed -n '\|^/\* README$|,\|^\*/$|p' <<< "$clean_content")"
58+
body="$(sed '\|^// ==UserScript==$|,\|^// ==/UserScript==$|d; \|^/\* README$|,\|^\*/$|d' <<< "$clean_content" | sed -n '\|[^\s]|,$p')"
59+
60+
# --- 2. CHECK FOR ID MISMATCH ---
61+
if [ "$id" != "${script_namespace##*/}" ]; then
62+
printf "Error: Userscript ID from filename does not match ID from namespace. Exiting.\n" >&2; exit 1
63+
fi
64+
65+
# --- 3. GENERATE DIST AND META VERSIONS ---
66+
header="$(sed \
67+
${readme_comment:+-e '\|// @description| s|$| See README for details.|'} \
68+
-e '\|// @namespace|d' \
69+
-e '\|// @author|d' \
70+
-e '\|// @homepageURL|d' \
71+
-e '\|// @supportURL|d' \
72+
-e '\|// @updateURL|d' \
73+
-e '\|// @downloadURL|d' \
74+
-e '\|// @version|a\
75+
// @namespace '"${BASE_URL%/*}"'\
76+
// @author '"${REPO_SLUG%/*}"'\
77+
// @homepageURL '"$BASE_URL"'#readme\
78+
// @supportURL '"$BASE_URL"'/issues\
79+
// @updateURL '"$BASE_URL_RAW/$META_DIR/$id.meta.js" <<< "$header")"
80+
81+
middle_content="${readme_comment:+$'\n\n'"$readme_comment"}"$'\n\n\n'
82+
83+
printf "%s" "$header" > "$META_DIR/$id.meta.js"
84+
85+
DOWNLOAD_URL_DIST="$BASE_URL_RAW/$DIST_DIR/$id.user.js"
86+
header_dist="$(sed "\|// @updateURL|a\// @downloadURL ${DOWNLOAD_URL_DIST}" <<< "$header")"
87+
printf "%s%s%s" "${header_dist}" "${middle_content}" "${body}" > "$DIST_DIR/$id.user.js"
88+
89+
minified_body="$(npx esbuild --minify --loader=js <<< "$body")"
90+
DOWNLOAD_URL_DIST_MIN="$BASE_URL_RAW/$DIST_DIR/$id.min.user.js"
91+
header_dist_min="$(sed "\|// @updateURL|a\// @downloadURL ${DOWNLOAD_URL_DIST_MIN}" <<< "$header")"
92+
printf "%s%s%s" "${header_dist_min}" "${middle_content}" "${minified_body}" > "$DIST_DIR/$id.min.user.js"
93+
94+
# --- 4. GENERATE DOCUMENTATION FILE ---
95+
doc_file="$DOCS_DIR/$id.md"
96+
printf "# %s\n%s\n\n" "$script_name" "$script_desc" > "$doc_file"
97+
98+
loc_count=$(npx cloc --quiet --sum-one --stdin-name="$id.user.js" - <<< "$body" | grep -m 1 'SUM:' | awk '{print $5}')
99+
((loc_count_total += loc_count))
100+
101+
install_badge="[![install standard](https://img.shields.io/badge/install-standard-006400)]($DOWNLOAD_URL_DIST)"
102+
install_min_badge="[![install minified](https://img.shields.io/badge/install-minified-64962a)]($DOWNLOAD_URL_DIST_MIN)"
103+
version_badge="[![version](https://img.shields.io/badge/version-$script_version-blue)](../../../../commits/main/$DIST_DIR/$id.user.js)"
104+
loc_count_badge="[![lines of code](https://img.shields.io/badge/loc-$loc_count-orange)](../../$DIST_DIR/$id.user.js)"
105+
printf "%s %s %s %s\n\n" "$install_badge" "$install_min_badge" "$version_badge" "$loc_count_badge" >> "$doc_file"
106+
107+
if [[ -n "$readme_comment" ]]; then
108+
printf "## Info\n" >> "$doc_file"
109+
printf "%s" "$readme_comment" | sed '1d; $d; $s|$|\n\n|' >> "$doc_file"
110+
fi
111+
112+
if [ -n "$(find "$SCREENSHOTS_DIR" -type f -iname "$id-*.*" 2>/dev/null)" ]; then
113+
printf "## Screenshots\n" >> "$doc_file"
114+
while IFS= read -r screenshot_path; do
115+
screenshot_filename="$(basename "$screenshot_path")"
116+
printf "![Screenshot](screenshots/%s)\n" "$screenshot_filename" >> "$doc_file"
117+
done < <(find "$SCREENSHOTS_DIR" -type f -iname "$id-*.*" | sort)
118+
fi
119+
120+
# --- 5. ADD ROW TO README TABLE ---
121+
escaped_script_name="$(sed 's#|#\\|#g' <<< "$script_name")"
122+
install_links="[Standard]($DOWNLOAD_URL_DIST) / [Minified]($DOWNLOAD_URL_DIST_MIN)"
123+
printf "| [%s](%s) | \`%s\` | \`%s\` | %s |\n" "$escaped_script_name" "$DOCS_DIR/$id.md" "$script_version" "$loc_count" "$install_links" >> "$TABLE_CONTENT_FILE"
124+
done
125+
126+
# --- FINALIZE README ---
127+
printf "Finalizing README.md...\n"
128+
userscript_count=$(find "$SRC_DIR" -name "*.user.js" | wc -l)
129+
(
130+
cat "$BEFORE_TABLE_FILE" | sed -E "s|(/badge/loc-)[0-9]+|\1$loc_count_total|; s|(/badge/userscripts-)[0-9]+|\1$userscript_count|"
131+
head -n2 "$TABLE_CONTENT_FILE"
132+
tail -n +3 "$TABLE_CONTENT_FILE" | sort
133+
cat "$AFTER_TABLE_FILE"
134+
) > README.md
135+
136+
# --- CLEANUP ---
137+
printf "Cleaning up temporary files...\n"
138+
rm -f "$BEFORE_TABLE_FILE" "$AFTER_TABLE_FILE" "$TABLE_CONTENT_FILE"
139+
140+
printf "Build process completed successfully!\n"

0 commit comments

Comments
 (0)