Skip to content

Instantly share code, notes, and snippets.

@MightyPork
Last active September 8, 2019 08:30
Show Gist options
  • Save MightyPork/9ae8b195023c57d2858da5e5c798a08c to your computer and use it in GitHub Desktop.
Save MightyPork/9ae8b195023c57d2858da5e5c798a08c to your computer and use it in GitHub Desktop.
userscript to make japanese posts in pleromafe bigger so kanji can be read
// ==UserScript==
// @name Bigger japanese
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://piggo.space/*
// @grant none
// ==/UserScript==
(function() {
function isKanji(s){
// magic regex from stack overflow
return !!s.match(/[\u4E00-\u9FAF\u3040-\u3096\u30A1-\u30FA\uFF66-\uFF9D\u31F0-\u31FF]/);
}
function rescanTL() {
console.log('scanning tl for jp posts');
document.querySelectorAll('.timeline-body .status-content').forEach((e) => {
let t = e.textContent;
if (isKanji(t)) {
e.style.fontSize = '130%';
}
});
}
setTimeout(function () {
rescanTL();
const targetNode = document.querySelector('.timeline-body > .timeline');
const config = { attributes: false, childList: true, subtree: true };
const callback = function(mutationsList, observer) {
rescanTL();
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment