Skip to content

Instantly share code, notes, and snippets.

@imyelo
Created April 24, 2022 07:28
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 imyelo/031f8d22613f2cafe1e23e2469ec3ca9 to your computer and use it in GitHub Desktop.
Save imyelo/031f8d22613f2cafe1e23e2469ec3ca9 to your computer and use it in GitHub Desktop.
UserScript - LGTM for WOA
// ==UserScript==
// @name Look goods to me!
// @version 0.1
// @author yelo <zhihuzeye@gmail.com>
// @match https://git.woa.com/**
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js
// ==/UserScript==
/* global $ */
"use strict";
const observe = (container, selector, handler) => {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
const $target = $(mutation.target);
const $form = $target.find(selector);
if ($form.length) {
handler($form);
}
});
});
observer.observe(container, {
childList: true,
subtree: true,
});
return () => observer.disconnect();
};
$(() => {
observe(document.body, ".review-change-form", ($form) => {
const MESSAGE = 'LGTM'
const $field = $form.find("#summary")
$field.val(MESSAGE);
$field.get(0).setSelectionRange(0, MESSAGE.length);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment