Skip to content

Instantly share code, notes, and snippets.

@foriequal0
Created February 20, 2019 16:18
Show Gist options
  • Save foriequal0/8c949efbf14212dd224e8130f82a36ab to your computer and use it in GitHub Desktop.
Save foriequal0/8c949efbf14212dd224e8130f82a36ab to your computer and use it in GitHub Desktop.
곽서심교.js
// ==UserScript==
// @name GSSK
// @namespace gist.github.com/foreiqual0
// @description 곽금주 서울대 심리학과 교수 => 곽서심교
// @include *
// @exclude file://*
// @version 1
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
const abbreviations = [
["곽금주 서울대 심리학과 교수", "곽서심교"],
["서울대 심리학과 곽금주 교수", "서심곽교"],
["서울대 심리학과 교수 곽금주", "서심교곽"],
["곽금주 서울대 교수", "곽서교"],
["서울대 곽금주 교수", "서곽교"],
["곽금주 교수", "곽교"],
];
function convert(root) {
if (!root) {
return;
}
for (const child of root.childNodes) {
convert(child);
}
if (root.nodeType == Node.TEXT_NODE) {
for (const [fullyQualified, abbreviated] of abbreviations) {
if (root.nodeValue.includes(fullyQualified)) {
root.nodeValue = root.nodeValue.replace(fullyQualified, abbreviated);
break;
}
}
}
}
function convertAndRegister() {
convert(document.body);
var observer = new MutationObserver(function(changes) {
for(var change of changes) {
convert(change.target);
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
if (document.readyState === "loading") { // Loading hasn't finished yet
document.addEventListener("DOMContentLoaded", convertAndRegister);
} else { // `DOMContentLoaded` has already fired
convertAndRegister();
}
})();
@brainstormot
Copy link

웃고갑니다ㅎㅎㅎ

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