Created
April 24, 2022 07:28
-
-
Save imyelo/031f8d22613f2cafe1e23e2469ec3ca9 to your computer and use it in GitHub Desktop.
UserScript - LGTM for WOA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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