From ca0c653a4a8bb13762c4570f5df1e2021b0b3a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=C5=A0olc=20AI?= Date: Wed, 4 Nov 2026 23:33:15 +0100 Subject: [PATCH] fix(gitlab-mark-viewed): support the rapid diffs viewer GitLab now binds v to Viewed by me itself, so the script no longer clicks the checkbox. It watches the result and advances to the next file. It also matches the diff-file element and the data-viewed-checkbox input. --- gitlab-mark-viewed.user.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gitlab-mark-viewed.user.js b/gitlab-mark-viewed.user.js index 8188405..9adb54e 100644 --- a/gitlab-mark-viewed.user.js +++ b/gitlab-mark-viewed.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name GitLab — mark file as Viewed with "v" // @namespace https://github.com/solcik/userscripts -// @version 0.5.1 -// @description In a GitLab merge request diff, press "v" to toggle the focused file's "Viewed" checkbox, advancing to the next file — pinned under the sticky header — only when marking one viewed. +// @version 0.5.2 +// @description In a GitLab merge request diff, press "v" (GitLab toggles the focused file's "Viewed" checkbox) and advance to the next file — pinned under the sticky header — only when marking one viewed. // @author David Solc // @match https://gitlab.com/*/-/merge_requests/* // @match https://git.vs-point.cz/*/-/merge_requests/* @@ -21,8 +21,8 @@ (function () { 'use strict'; - const FILE = '.diff-file.file-holder'; - const REVIEW_CHECKBOX = "[data-testid='fileReviewCheckbox']"; + const FILE = 'diff-file, .diff-file.file-holder'; + const REVIEW_CHECKBOX = "[data-testid='fileReviewCheckbox'], input[data-viewed-checkbox]"; const NEXT_FILE_KEY = 'j'; const EDGE = 4; const SETTLE_MS = 400; @@ -108,22 +108,22 @@ })(); } + // GitLab now binds "v" ("Viewed by me") itself. Clicking the checkbox here + // too would toggle it twice, so let GitLab toggle and only watch the result. Mousetrap.bind('v', function () { const file = focusedFile(); const checkbox = file && file.querySelector(REVIEW_CHECKBOX); if (!checkbox) return; - // Un-reviewing expands the file again, which is the whole point of pressing - // "v" on an already-viewed file — stay put so it can actually be read. - const marking = !checkbox.checked; - - checkbox.click(); - if (!marking) return; - + const was = checkbox.checked; const key = fileKey(file); - requestAnimationFrame(function () { + + setTimeout(function () { + // Un-reviewing expands the file again, which is the whole point of + // pressing "v" on an already-viewed file — stay put so it can be read. + if (was || !checkbox.checked) return; goToNextFile(); pinNextFile(key); - }); + }, 50); }); })();