Skip to content

Instantly share code, notes, and snippets.

@ViBiOh
Last active August 27, 2024 08:23
Show Gist options
  • Save ViBiOh/916ecc18f323448dd5773674d9cab381 to your computer and use it in GitHub Desktop.
Save ViBiOh/916ecc18f323448dd5773674d9cab381 to your computer and use it in GitHub Desktop.

TL; DR

{
  const LABELS = [
    ["👏 praise", "Praises highlight something positive. Try to leave at least one of these comments per review. Do not leave false praise (which can actually be damaging). Do look for something to sincerely praise."],
    ["🥜 nitpick", " Nitpicks are trivial preference-based requests. These should be non-blocking by nature."],
    ["💬 suggestion", "Suggestions propose improvements to the current subject. It's important to be explicit and clear on what is being suggested and why it is an improvement. Consider using patches and the blocking or non-blocking [decorations to further communicate your intent."],
    ["⚠️ issue", " Issues highlight specific problems with the subject under review. These problems can be user-facing or behind the scenes. It is strongly recommended to pair this comment with a suggestion. If you are not sure if a [problem exists or not, consider leaving a question."],
    ["📋 todo", "TODO's are small, trivial, but necessary changes. Distinguishing todo comments from issues: or suggestions: helps direct the reader's attention to comments requiring more involvement."],
    ["❓ question", "Questions are appropriate if you have a potential concern but are not quite sure if it's relevant or not. Asking the author for clarification or investigation can lead to a quick resolution."],
    ["💭 thought", " Thoughts represent an idea that popped up from reviewing. These comments are non-blocking by nature, but they are extremely valuable and can lead to more focused initiatives and mentoring opportunities."],
    ["👷 chore", " Chores are simple tasks that must be done before the subject can be “officially” accepted. Usually, these comments reference some common process. Try to leave a link to the process description so that the reader knows how to resolve the chore."],
    ["📝 note", "Notes are always non-blocking and simply highlight something the reader should take note of."],
  ];
  const form = document.querySelector(".new_saved_reply");
  const authenticity_token = encodeURIComponent(
    form.querySelector("[name=authenticity_token]").value
  );
  Promise.all(
    LABELS.map(([type, note], index) => {
      const title = encodeURIComponent(`${type[0].toUpperCase()}${type.slice(1)}`);
      const body = encodeURIComponent(`<!-- ${note}  -->\n**${type}:** ‏`);
      return fetch("replies", {
        headers: {
          accept:
            "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
          "accept-language": "en-US,en;q=0.9",
          "cache-control": "no-cache",
          "content-type": "application/x-www-form-urlencoded",
          pragma: "no-cache",
          "sec-fetch-dest": "document",
          "sec-fetch-mode": "navigate",
          "sec-fetch-site": "same-origin",
          "sec-fetch-user": "?1",
          "upgrade-insecure-requests": "1",
        },
        referrer: "https://github.com/settings/replies",
        referrerPolicy: "strict-origin-when-cross-origin",
        body: `authenticity_token=${authenticity_token}&title=${title}&saved_reply_id=&body=${body}&path=&line=&start_line=&preview_side=&preview_start_side=&start_commit_oid=&end_commit_oid=&base_commit_oid=&comment_id=`,
        method: "POST",
        mode: "cors",
        credentials: "include",
      })
    })
  ).then(() => console.log("🎉 All added! Refresh the page!"));
}

Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment