Skip to content

Commit

Permalink
automatically generated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Aug 15, 2024
1 parent 7386768 commit 8a1bbe3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 0 additions & 2 deletions fuglane.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// @match https://fuglane.it.ntnu.no/*
// @grant none
// @icon https://www.google.com/s2/favicons?sz=64&domain=ntnu.no
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/fuglane.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/fuglane.user.js
// ==/UserScript==

(function() {
Expand Down
58 changes: 58 additions & 0 deletions generate-readme.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"# Monkey Magic"
""
"TamperMonkey scripts for å gjøre websider bedre. (Fuglane, Innsida osv.)"
""
"# Scripts"
""

# Define the directory containing the user scripts
$UserScripts = "."

# Get all .user.js files in the specified directory
$userJsFiles = Get-ChildItem -Path $UserScripts -Filter *.user.js

$regEx = [regex]'\/\/\s+@(\w+)\s+(.+)'

# Initialize an array to hold the table rows
$tableRows = @()

# Loop through each file
foreach ($file in $userJsFiles) {
# Read the file content
$content = Get-Content -Path $file.FullName

$i = 0
$endOfCommentBlock = $false
$name = ""
$description = ""

do {
$regExMatch = $regEx.Match($content[$i])

if ($regExMatch.Success) {
$key = $regExMatch.Groups[1].Value
$value = $regExMatch.Groups[2].Value

if ($key -eq 'name') {
$name = $value
} elseif ($key -eq 'description') {
$description = $value
}
}

# Check if the current line is the end of the comment block
if ($content[$i] -match '^\s*\/\/\s?==\/UserScript==') {
$endOfCommentBlock = $true
}

$i++
} while (($i -lt $content.Length) -and (-not $endOfCommentBlock))

# Add the row to the table
$tableRows += "| $($file.Name) | $name | $description |"
}

# Output the markdown table
Write-Output "| Filename | Name | Description |"
Write-Output "|----------|------|-------------|"
$tableRows | ForEach-Object { Write-Output $_ }

0 comments on commit 8a1bbe3

Please sign in to comment.