GitLab - Default Add Comment

Makes "Add comment now" the default action in GitLab and remove the Start a Review

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
squiter
日安装量
0
总安装量
1
评分
0 0 0
版本
1.0
创建于
2026-02-20
更新于
2026-02-20
大小
1.9 KB
许可证
MIT
适用于

What this script does

GitLab normally defaults to Start a review, which makes pressing Enter start a review instead of posting a comment immediately.

This userscript changes that behavior by:

  • Hiding the Start a review button
  • Making Add comment now the default action
  • Pressing Enter submits the comment
  • Pressing Shift + Enter inserts a newline (normal markdown behavior)

The script works on GitLab merge request discussions and comment forms.


Why this exists

Many users prefer fast single comments instead of review mode.
This script optimizes the workflow to behave more like chat or GitHub-style commenting.


Technical details

  • Uses stable data-testid selectors when available.
  • Uses a MutationObserver because GitLab is a Vue SPA and frequently re-renders the DOM.
  • The script does not bypass GitLab logic — it clicks GitLab’s own button, so validation and quick actions still work normally.

Compatibility

✔ GitLab.com
✔ Most self-hosted GitLab instances (if URL match is adjusted)

Tested with the modern GitLab UI (Vue-based editor).


Known limitations

  • GitLab UI updates may break selectors in the future.
  • The script only acts when the comment button is enabled.
  • If another extension modifies GitLab comments, conflicts are possible.

Safety

This script:

  • Does not send data anywhere
  • Does not modify network requests
  • Runs entirely locally in your browser

Customization

If you want different behavior:

  • Change Enter to submit only with Ctrl/Cmd
  • Keep Start Review visible
  • Enable/disable per page

Feel free to fork and modify.