From 64fac6248e32145346f094b59cd5b859540d46e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Andreas=20Nilsen?= Date: Fri, 3 Oct 2025 10:23:46 +0200 Subject: [PATCH] moved readme template and generation script to doc dir --- .github/workflows/generate-readme.yml | 6 +++--- README.md | 20 +++++++++---------- ReadmeTemplate.md => doc/ReadmeTemplate.md | 0 .../generate-readme.ps1 | 14 +++++++------ 4 files changed, 21 insertions(+), 19 deletions(-) rename ReadmeTemplate.md => doc/ReadmeTemplate.md (100%) rename generate-readme.ps1 => doc/generate-readme.ps1 (91%) diff --git a/.github/workflows/generate-readme.yml b/.github/workflows/generate-readme.yml index f8cd3fb..88b3224 100644 --- a/.github/workflows/generate-readme.yml +++ b/.github/workflows/generate-readme.yml @@ -4,8 +4,8 @@ on: branches: ['main'] paths: - '**.user.js' - - 'generate-readme.ps1' - - 'ReadmeTemplate.md' + - 'doc/generate-readme.ps1' + - 'doc/ReadmeTemplate.md' - 'doc/**' name: Generate Readme @@ -20,7 +20,7 @@ jobs: - name: Generate Readme shell: pwsh run: | - ./generate-readme.ps1 | Out-File -filePath README.md -Encoding UTF8 + ./doc/generate-readme.ps1 | Out-File -filePath README.md -Encoding UTF8 git config user.email "m365-bot@ntnu.no" git config user.name "github-actions[bot]" diff --git a/README.md b/README.md index 1674319..10e9c5a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.) ### BAS - Modern Style Toggle - - **Install:** [![](https://img.shields.io/badge/modern--bas.user.js-1.0.13-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/modern-bas/modern-bas.user.js) + - **Install:** [![](https://img.shields.io/badge/modern--bas.user.js-1.0.13-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/modern-bas/modern-bas.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://bas.ntnu.no/*` - **Exclude:** @@ -41,7 +41,7 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.) - **Description:** Apply modern styling to BAS/Cereweb with toggle between modern and classic ### BAS - Quick Search - - **Install:** [![](https://img.shields.io/badge/bas--search.user.js-1.8.5-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/bas-search/bas-search.user.js) + - **Install:** [![](https://img.shields.io/badge/bas--search.user.js-1.8.5-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/bas-search/bas-search.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://bas.ntnu.no/*` - **Description:** Quick search using `Ctrl` + `Shift` + `F` hotkey, group search with "g:" and person search with "p:" prefix. Navigate tabs with Ctrl + Left/Right keys. Navigate search results with up and down keys. @@ -60,19 +60,19 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.) ![Search GIF](scripts/bas-search/bas-search-lowres.gif) ### Diri.ai - Remove blur - - **Install:** [![](https://img.shields.io/badge/diri.user.js-0.1.1-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/diri/diri.user.js) + - **Install:** [![](https://img.shields.io/badge/diri.user.js-0.1.1-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/diri/diri.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://diri.ai/*` - **Description:** Sets --blur-xs to 0px instead of 4px for diri.ai ### Feide - Auto-Press Microsoft Sign-In. - - **Install:** [![](https://img.shields.io/badge/feide--microsoft.user.js-1.1.3-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/feide-microsoft/feide-microsoft.user.js) + - **Install:** [![](https://img.shields.io/badge/feide--microsoft.user.js-1.1.3-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/feide-microsoft/feide-microsoft.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://idp.feide.no/simplesaml/module.php/*` - **Description:** Automatically press the Microsoft sign-in button. ### Fuglane - Issue links - - **Install:** [![](https://img.shields.io/badge/fuglane.user.js-1.3.6-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/fuglane/fuglane.user.js) + - **Install:** [![](https://img.shields.io/badge/fuglane.user.js-1.3.6-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/fuglane/fuglane.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** - `https://fuglane.it.ntnu.no/display/*` @@ -82,25 +82,25 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.) - **Description:** Replace NTNU issue numbers, change numbers and upn's with clickable links to TopDesk ### Innsida - Custom CSS - - **Install:** [![](https://img.shields.io/badge/innsida--custom--css.user.js-1.2-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/innsida-custom-css/innsida-custom-css.user.js) + - **Install:** [![](https://img.shields.io/badge/innsida--custom--css.user.js-1.2-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/innsida-custom-css/innsida-custom-css.user.js) - **Author:** Magnus Børnes (magnborn@ntnu.no) - **Match:** `https://innsida.ntnu.no/*` - **Description:** Custom CSS and Text Removal for innsida.ntnu.no ### Innsida - Quick Search - - **Install:** [![](https://img.shields.io/badge/innsida--search.user.js-1.2.0-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/innsida-search/innsida-search.user.js) + - **Install:** [![](https://img.shields.io/badge/innsida--search.user.js-1.2.0-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/innsida-search/innsida-search.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://innsida.ntnu.no/*` - **Description:** `Ctrl` + `Shift` + `F` to search on Innsida ### M365 Admin - PIM Activate Hotkey - - **Install:** [![](https://img.shields.io/badge/m365--admin.user.js-1.0.0-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/m365-admin/m365-admin.user.js) + - **Install:** [![](https://img.shields.io/badge/m365--admin.user.js-1.0.0-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/m365-admin/m365-admin.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://portal.azure.com/*` - **Description:** `Ctrl` + `Enter` to Activate PIM role instead of having to manually click the `Activate` button. ### TopDesk - Copy Issuenumber - - **Install:** [![](https://img.shields.io/badge/topdesk.user.js-1.2.3-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/topdesk/topdesk.user.js) + - **Install:** [![](https://img.shields.io/badge/topdesk.user.js-1.2.3-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/topdesk/topdesk.user.js) - **Author:** Øyvind Nilsen (on@ntnu.no) - **Match:** `https://hjelp.ntnu.no/tas/secure/mango/window/*` - **Description:** Copies the issue number if you click it in TopDesk or with the hotkey `ctrl` + `alt` + `c`. It copies plain text and a clickable HTML version. So if the place you paste supports HTML, you can paste a clickable link to the issue. @@ -109,7 +109,7 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.) ![Demo GIF](scripts/topdesk/topdesk.gif) ### TOPdesk - Highlight Summary - - **Install:** [![](https://img.shields.io/badge/topdesk--highlight--summary.user.js-1.6-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/topdesk-highlight-summary/topdesk-highlight-summary.user.js) + - **Install:** [![](https://img.shields.io/badge/topdesk--highlight--summary.user.js-1.6-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/topdesk-highlight-summary/topdesk-highlight-summary.user.js) - **Author:** Magnus Børnes (magnborn@ntnu.no) - **Match:** `https://hjelp.ntnu.no/tas/secure/mango/window/*` - **Description:** Highlight the summary section in a box with a slightly yellow-orange background diff --git a/ReadmeTemplate.md b/doc/ReadmeTemplate.md similarity index 100% rename from ReadmeTemplate.md rename to doc/ReadmeTemplate.md diff --git a/generate-readme.ps1 b/doc/generate-readme.ps1 similarity index 91% rename from generate-readme.ps1 rename to doc/generate-readme.ps1 index 58e8aa3..22c1f5b 100644 --- a/generate-readme.ps1 +++ b/doc/generate-readme.ps1 @@ -1,5 +1,7 @@ # Define the directory containing the user scripts -$UserScripts = "scripts" +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$rootDir = Split-Path -Parent $scriptDir +$UserScripts = Join-Path $rootDir "scripts" # Get all .user.js files in the scripts subdirectories $userJsFiles = Get-ChildItem -Path $UserScripts -Filter "*.user.js" -Recurse | Select-Object fullname, name, @{ Name = 'NameTag'; Expression = { $name_tag = ([regex]"@name\s+(.+)").Match((Get-Content $_.fullname -Raw)).Groups[1].value; if ($name_tag -eq "") { $_.name} else { $name_tag } }} | sort NameTag @@ -103,7 +105,7 @@ foreach ($file in $userJsFiles) { $scriptList += " - **Install:** " if ($autoUpdate) { $color = "green" } else { $color = "blue" } # Get the relative path from the root, replacing backslashes with forward slashes for URLs - $relativePath = $file.FullName.Replace((Get-Location).Path + "\", "").Replace("\", "/") + $relativePath = $file.FullName.Replace($rootDir + "\", "").Replace("\", "/") $scriptList += New-MDImage -Subject "$($file.Name)" -Status "$version" -Color $color -Link "https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/$relativePath" if ($author) { $scriptList += "`n - **Author:** $author`n" @@ -130,15 +132,15 @@ foreach ($file in $userJsFiles) { $scriptList += " - **Description:** $description`n" $baseName = $file.Name -replace '\.user\.js$', '' - $scriptDir = Split-Path $file.FullName -Parent - $docFile = Join-Path $scriptDir "$baseName.md" + $currentScriptDir = Split-Path $file.FullName -Parent + $docFile = Join-Path $currentScriptDir "$baseName.md" if (Test-Path $docFile) { $scriptList += "`n" $extraDoc = Get-Content $docFile -Raw # Replace relative image links with absolute links from the script's subfolder - $relativeScriptPath = $scriptDir.Replace((Get-Location).Path + "\", "").Replace("\", "/") + $relativeScriptPath = $currentScriptDir.Replace($rootDir + "\", "").Replace("\", "/") # Replace relative image links (simple filenames with common image extensions) $extraDoc = $extraDoc -replace '\!\[([^\]]+)\]\(([^/)]+\.(gif|png|jpg|jpeg|webp|svg))\)', "![`$1]($relativeScriptPath/`$2)" @@ -149,6 +151,6 @@ foreach ($file in $userJsFiles) { } -$template = Get-Content .\ReadmeTemplate.md +$template = Get-Content (Join-Path $scriptDir "ReadmeTemplate.md") $template = $template -replace '{content_list}', $content_list $template -replace '{scriptlist}', $scriptList \ No newline at end of file