Skip to content

Commit

Permalink
Merge pull request #45 from M365-Drift/crazycleanup
Browse files Browse the repository at this point in the history
Crazycleanup
  • Loading branch information
on authored Oct 3, 2025
2 parents 7f74f9a + 631aeae commit e07982f
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 119 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/generate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]"
Expand Down
79 changes: 53 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/modern-bas/modern-bas.user.js)
- **Author:** Øyvind Nilsen (on@ntnu.no)
- **Match:** `https://bas.ntnu.no/*`
- **Exclude:**
Expand All @@ -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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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.
Expand All @@ -57,22 +57,22 @@ TamperMonkey scripts to improve sites (Fuglane, Innsida etc.)
- On the login page, the username field is automatically focused.

#### Video:
![Search GIF](doc/bas-search-lowres.gif)
![Search GIF](/home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/scripts/fuglane/fuglane.user.js)
- **Author:** Øyvind Nilsen (on@ntnu.no)
- **Match:**
- `https://fuglane.it.ntnu.no/display/*`
Expand All @@ -82,63 +82,90 @@ 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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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.


![Demo GIF](doc/topdesk.gif)
![Demo GIF](/home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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/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//home/ubuntu/actions-runner/_work/MonkeyMagic/MonkeyMagic/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


# Contribute
## Basic Contribution

## Getting Started
1. Clone the repository
```bash
git clone git@git.ntnu.no:M365-Drift/MonkeyMagic.git
cd MonkeyMagic
```
2. Pull the latest changes. (Important since the README.md is generated)
2. If there have been made changes in the repository after you cloned it you should pull the latest changes. (Important since the README.md is auto generated)
```bash
git pull
```
3. Add your script to the repository
```bash
git add myscript.user.js
git commit -m "Added my script"
git push
```
4. A Github Action will be automatically triggered and generate a new README.md file.

## Advanced Contribution
## Creating Your UserScript

### Hello World Example
Here's a simple hello world UserScript to get you started:

### Auto Update
To enable auto update of your UserScript, you need to add the following lines (change the filename to your filename) to the top of your script. This will make TamperMonkey check for updates every 24 hours.
```javascript
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/bas-search.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/bas-search.user.js
// ==UserScript==
// @name Hello World Example
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/
// @version 1.0.0
// @description A simple hello world example
// @author Your Name (your.email@ntnu.no)
// @match https://example.com/*
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/hello-world/hello-world.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/hello-world/hello-world.user.js
// @grant none
// ==/UserScript==

(function() {
'use strict';
console.log('Hello World from MonkeyMagic!');
alert('Hello World!');
})();
```

### Important Guidelines
- **Namespace**: Always use `https://git.ntnu.no/M365-Drift/MonkeyMagic/` as your namespace
- **Folder Structure**: Create a subfolder under `scripts/` for your script (e.g., `scripts/hello-world/`)
- **Auto Update**: Include `@updateURL` and `@downloadURL` pointing to your script's location in the repository. This enables automatic updates every 24 hours in TamperMonkey.

### Adding Your Script
1. Create a new folder under `scripts/` with your script name
2. Place your `.user.js` file in that folder
3. Add any documentation or media files to the same folder
4. Commit and push your changes:
```bash
git add scripts/your-script-name/
git commit -m "Added your-script-name userscript"
git push
```
5. A GitHub Action will automatically update the README.md file with your script information.
49 changes: 0 additions & 49 deletions ReadmeTemplate.md

This file was deleted.

76 changes: 76 additions & 0 deletions doc/ReadmeTemplate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<div align="center">
<img src="doc/mm_logo.png" alt="MonkeyMagic Logo" />
</div>

# Monkey Magic 🐒🪄

TamperMonkey scripts to improve sites (Fuglane, Innsida etc.)

# How to use
1. Install the TamperMonkey extension for your browser
2. Enable permission to use User Scripts.
- Open extension settings by right-clicking the Tampermonkey icon (1) and selecting **"Manage Extension"** (2).
![manage extension screenshot](doc/manage_extension.jpg)
- Locate and enable the **"Allow User Scripts"** toggle.
![allow user scripts screenshot](doc/userscripts_toggle.png)
3. Click on the ![](https://img.shields.io/badge/Install-Link-green.svg) for the script you want to install (in the list below)
4. TamperMonkey should open and ask you to install the script

# Scripts
{content_list}
{scriptlist}

# Contribute

## Getting Started
1. Clone the repository
```bash
git clone git@git.ntnu.no:M365-Drift/MonkeyMagic.git
cd MonkeyMagic
```
2. If there have been made changes in the repository after you cloned it you should pull the latest changes. (Important since the README.md is auto generated)
```bash
git pull
```

## Creating Your UserScript

### Hello World Example
Here's a simple hello world UserScript to get you started:

```javascript
// ==UserScript==
// @name Hello World Example
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/
// @version 1.0.0
// @description A simple hello world example
// @author Your Name (your.email@ntnu.no)
// @match https://example.com/*
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/hello-world/hello-world.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/hello-world/hello-world.user.js
// @grant none
// ==/UserScript==

(function() {
'use strict';
console.log('Hello World from MonkeyMagic!');
alert('Hello World!');
})();
```

### Important Guidelines
- **Namespace**: Always use `https://git.ntnu.no/M365-Drift/MonkeyMagic/` as your namespace
- **Folder Structure**: Create a subfolder under `scripts/` for your script (e.g., `scripts/hello-world/`)
- **Auto Update**: Include `@updateURL` and `@downloadURL` pointing to your script's location in the repository. This enables automatic updates every 24 hours in TamperMonkey.

### Adding Your Script
1. Create a new folder under `scripts/` with your script name
2. Place your `.user.js` file in that folder
3. Add any documentation or media files to the same folder
4. Commit and push your changes:
```bash
git add scripts/your-script-name/
git commit -m "Added your-script-name userscript"
git push
```
5. A GitHub Action will automatically update the README.md file with your script information.
27 changes: 17 additions & 10 deletions generate-readme.ps1 → doc/generate-readme.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Define the directory containing the user scripts
$UserScripts = "."
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$rootDir = Split-Path -Parent $scriptDir
$UserScripts = Join-Path $rootDir "scripts"

# Get all .user.js files in the specified directory
#$userJsFiles = Get-ChildItem -Path $UserScripts -Filter "*.user.js" | Sort-Object Name
$userJsFiles = Get-ChildItem -Path $UserScripts -Filter "*.user.js" | 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
# 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

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

Expand Down Expand Up @@ -103,7 +104,9 @@ foreach ($file in $userJsFiles) {
$scriptList += "$script_heading`n`n"
$scriptList += " - **Install:** "
if ($autoUpdate) { $color = "green" } else { $color = "blue" }
$scriptList += New-MDImage -Subject "$($file.Name)" -Status "$version" -Color $color -Link "https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/$($file.Name)"
# Get the relative path from the root, replacing backslashes with forward slashes for URLs
$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"
}
Expand All @@ -129,13 +132,17 @@ foreach ($file in $userJsFiles) {
$scriptList += " - **Description:** $description`n"

$baseName = $file.Name -replace '\.user\.js$', ''
$currentScriptDir = Split-Path $file.FullName -Parent
$docFile = Join-Path $currentScriptDir "$baseName.md"

if (Test-Path "doc/$baseName.md") {
if (Test-Path $docFile) {
$scriptList += "`n"
$extraDoc = Get-Content "doc/$baseName.md" -Raw
$extraDoc = Get-Content $docFile -Raw

# Replace relative image links with absolute links
$extraDoc = $extraDoc | % { $_ -replace '\!\[(.+)\]\((?!doc\/)(.+)\)', "![`$1](doc/`$2)" }
# Replace relative image links with absolute links from the script's subfolder
$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)"

$scriptList += "`n"
$scriptList += $extraDoc
Expand All @@ -144,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
File renamed without changes
File renamed without changes.
6 changes: 3 additions & 3 deletions bas-search.user.js → scripts/bas-search/bas-search.user.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// ==UserScript==
// @name BAS - Quick Search
// @namespace http://tampermonkey.net/
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/
// @version 1.8.5
// @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.
// @author Øyvind Nilsen (on@ntnu.no)
// @match https://bas.ntnu.no/*
// @grant none
// @run-at document-end
// @icon https://www.google.com/s2/favicons?sz=64&domain=ntnu.no
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/bas-search.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/bas-search.user.js
// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/bas-search/bas-search.user.js
// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/scripts/bas-search/bas-search.user.js
// ==/UserScript==

(function() {
Expand Down
Loading

0 comments on commit e07982f

Please sign in to comment.