Skip to content

Instantly share code, notes, and snippets.

@PiDelport
Last active October 21, 2023 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PiDelport/74453fa91872a9e51c7858550ff3cab3 to your computer and use it in GitHub Desktop.
Save PiDelport/74453fa91872a9e51c7858550ff3cab3 to your computer and use it in GitHub Desktop.
GitLab Draft Comments (User Script)
// ==UserScript==
// @name GitLab Draft Comments
// @description Alert for and list forgotten GitLab draft comments.
// @namespace https://github.com/PiDelport/
// @author Pi Delport <pjdelport@gmail.com>
// @version 1.0
// @license MIT
// @homepageURL https://gist.github.com/PiDelport/74453fa91872a9e51c7858550ff3cab3
//
// @grant GM.registerMenuCommand
// @match https://gitlab.com/*
// ==/UserScript==
'use strict';
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/24391
function workaround() {
const entries = Object.entries(localStorage).filter(([key, value]) => key.startsWith('autosave/'));
if (0 < entries.length) {
const summary = entries.map(([key, value]) => `${key}:\n${value}\n\n`).concat();
alert(`Warning: ${entries.length} draft comments (see console)\n\n${summary}`);
entries.forEach(([key, value]) => console.log({key, value}))
}
}
(function() {
GM.registerMenuCommand('List draft comments (see console)', workaround);
workaround();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment