Skip to content

Commit 228a722

Browse files
committed
chore: initial commit
Personal Violentmonkey userscripts. Each script declares @updateURL so Violentmonkey auto-updates from main on its own. - gitlab-mark-viewed.user.js: press "v" on a GitLab MR diff to toggle the focused file's "Viewed" checkbox.
0 parents  commit 228a722

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
*.swp
3+
.idea/
4+
.vscode/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# userscripts
2+
3+
Personal collection of [Violentmonkey](https://violentmonkey.github.io/) userscripts.
4+
5+
Each script declares `@updateURL` pointing back at this repo, so once installed
6+
Violentmonkey auto-updates from `main` on its own.
7+
8+
## Install
9+
10+
Open a script's raw URL in Firefox with Violentmonkey installed — it detects
11+
the `==UserScript==` header and prompts to install.
12+
13+
| Script | Install | Description |
14+
|---|---|---|
15+
| `gitlab-mark-viewed.user.js` | [install](https://raw.githubusercontent.com/solcik/userscripts/main/gitlab-mark-viewed.user.js) | Press `v` on a GitLab MR diff to toggle the focused file's "Viewed" checkbox. Works on any GitLab instance (gitlab.com, self-hosted). |
16+
17+
## Authoring
18+
19+
- Bump `@version` on every change (Violentmonkey only updates when the version increases).
20+
- Keep `@match` patterns narrow enough to avoid running on unrelated pages.
21+
- Prefer `@require` (loaded once, cached) over inlining vendored libraries.
22+
- `@grant none` whenever possible — the script then runs in the page's own
23+
context and can't escalate privileges.
24+
25+
## License
26+
27+
MIT — see header in each `.user.js` file.

gitlab-mark-viewed.user.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ==UserScript==
2+
// @name GitLab — mark file as Viewed with "v"
3+
// @namespace https://github.com/solcik/userscripts
4+
// @version 0.2.0
5+
// @description In a GitLab merge request diff, press "v" to toggle the focused file's "Viewed" checkbox.
6+
// @author David Solc
7+
// @match *://*/-/merge_requests/*/diffs
8+
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
9+
// @homepageURL https://github.com/solcik/userscripts
10+
// @supportURL https://github.com/solcik/userscripts/issues
11+
// @updateURL https://raw.githubusercontent.com/solcik/userscripts/main/gitlab-mark-viewed.user.js
12+
// @downloadURL https://raw.githubusercontent.com/solcik/userscripts/main/gitlab-mark-viewed.user.js
13+
// @require https://cdn.jsdelivr.net/npm/mousetrap@1.6.5/mousetrap.min.js
14+
// @grant none
15+
// @license MIT
16+
// ==/UserScript==
17+
18+
// Original idea: https://gist.github.com/CodeBrauer/2d5814262e53fafb4228ebcda08154d9
19+
20+
(function () {
21+
'use strict';
22+
Mousetrap.bind('v', function () {
23+
const cb = document.querySelector("[data-testid='fileReviewCheckbox']");
24+
if (cb) cb.click();
25+
});
26+
})();

0 commit comments

Comments
 (0)