Skip to content

Instantly share code, notes, and snippets.

@hogashi
Created July 9, 2023 10:26
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 hogashi/0baac922b1dce89246d10c4bacb5a5cb to your computer and use it in GitHub Desktop.
Save hogashi/0baac922b1dce89246d10c4bacb5a5cb to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name misskey-nya2na
// @namespace misskey-nya2na
// @version 0.1
// @description replace misskey notes にゃ to ruby-ed な(にゃ)
// @author hogashi
// @match https://misskey.io/
// @grant none
// ==/UserScript==
(function() {
'use strict';
const onLoad = () => {
const targetNode = document.querySelector('[data-sticky-container-header-height] div:has(> div > article)');
const onMutate = () => {
targetNode.querySelectorAll('article span:not(:has(.nya2na))').forEach(span => {
span.innerHTML = span.innerHTML.replace(/にゃ/g, '<ruby class="nya2na">な<rp>(</rp><rt>にゃ</rt><rp>)</rp></ruby>');
});
};
const observer = new MutationObserver(onMutate);
// Start observing the target node for configured mutations
observer.observe(targetNode, { childList: true });
onMutate();
};
window.addEventListener('load', () => {
console.log('nya2na: window loaded');
setTimeout(() => {
console.log('nya2na: onLoad');
onLoad();
}, 5000);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment