Skip to content

Commit

Permalink
Merge pull request #8 from M365-Drift/newerdoc
Browse files Browse the repository at this point in the history
Newerdoc
  • Loading branch information
on authored and GitHub Enterprise committed Aug 26, 2024
2 parents 952afa7 + cce8d56 commit 88449ac
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/generate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ on:
workflow_dispatch:
push:
branches: ['main']
paths: ['**.user.js', 'generate-readme.ps1', 'ReadmeTemplate.md']

paths:
- '**.user.js'
- 'generate-readme.ps1'
- 'ReadmeTemplate.md'
- 'doc/**'

name: Generate Readme

jobs:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ TamperMonkey scripts for å gjøre websider bedre. (Fuglane, Innsida osv.)
- **Author:** Øyvind Nilsen (on@ntnu.no)
- **Match:** `https://bas.ntnu.no/*`
- **Description:** Show a textbox on `Alt` + `/` key press and redirect to Cereweb search on Enter key press. Supports group search with "g:" prefix and accounts if you use no prefix or "a:" prefix.
### Feide - Auto-Press Microsoft Sign-In.

- **Install:** [![](https://img.shields.io/badge/feide--microsoft.user.js-1.0-blue.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/feide-microsoft.user.js)
- **Author:** Øyvind Nilsen (on@ntnu.no)
- **Match:** `https://idp.feide.no/simplesaml/*`
- **Description:** Automatically press the Microsoft sign-in button after a countdown, with options to cancel or trigger manually.

![Login GIF](doc/feide-microsoft.gif)
### Fuglane - Issue links

- **Install:** [![](https://img.shields.io/badge/fuglane.user.js-1.3.1-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/fuglane.user.js)
Expand All @@ -27,6 +35,8 @@ TamperMonkey scripts for å gjøre websider bedre. (Fuglane, Innsida osv.)
- **Author:** Øyvind Nilsen (on@ntnu.no)
- **Match:** `https://hjelp.ntnu.no/*`
- **Description:** Copies the issue number if you click it in TopDesk

![Demo GIF](doc/topdesk.gif)
### YR.no - Hotkeys

- **Install:** [![](https://img.shields.io/badge/yr.user.js-1.2.1-green.svg)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/yr.user.js)
Expand Down
Binary file added doc/feide-microsoft.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/feide-microsoft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Login GIF](feide-microsoft.gif)
Binary file added doc/topdesk.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/topdesk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Demo GIF](topdesk.gif)
54 changes: 54 additions & 0 deletions feide-microsoft.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ==UserScript==
// @name Feide - Auto-Press Microsoft Sign-In.
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic
// @version 1.0
// @description Automatically press the Microsoft sign-in button after a countdown, with options to cancel or trigger manually.
// @author Øyvind Nilsen (on@ntnu.no)
// @match https://idp.feide.no/simplesaml/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=feide.no
// @grant none
// ==/UserScript==

(function() {
'use strict';

const button = document.getElementById('microsoft-signin-button');
if (!button) return;

let countdown = 5;
let countdownInterval;

function updateButtonText() {
button.value = `Use work or school account (${countdown}s)`;
}

function startCountdown() {
updateButtonText();
countdownInterval = setInterval(() => {
countdown--;
if (countdown <= 0) {
updateButtonText();
clearInterval(countdownInterval);
button.click();
} else {
updateButtonText();
}
}, 1000);
}

function stopCountdown() {
clearInterval(countdownInterval);
button.value = 'Use work or school account';
}

document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
stopCountdown();
} else if (event.ctrlKey && event.key === 'Enter') {
clearInterval(countdownInterval);
button.click();
}
});

startCountdown();
})();
14 changes: 14 additions & 0 deletions generate-readme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ foreach ($file in $userJsFiles) {
}
$scriptList += " - **Match:** ``$match```n"
$scriptList += " - **Description:** $description`n"

$baseName = $file.Name -replace '\.user\.js$', ''

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

# Replace relative image links with absolute links
$extraDoc = $extraDoc -replace '\!\[(.+)\]\((?!doc\/)(.+)\)', '![$1](doc/$2)'

$scriptList += $extraDoc
$scriptList += "`n"
}

}

#$tableRows | ForEach-Object { Write-Output $_ }
Expand Down

0 comments on commit 88449ac

Please sign in to comment.