Skip to content

Instantly share code, notes, and snippets.

@AmaiSaeta
Forked from udzura/kokubun.user.js
Created December 12, 2012 10:07
Show Gist options
  • Save AmaiSaeta/4266557 to your computer and use it in GitHub Desktop.
Save AmaiSaeta/4266557 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ねえねえ今どんな気持ち?
// @namespace http://amaisaeta.seesaa.net/
// @description 国分太一fier
// @include https://www.facebook.com/*
// @version 1.00.20121213
// ==/UserScript==
(function () {
var aa = [ // {{{
"ねぇねぇ、今どんな気持ち?",
"        ∩___∩                     ∩___∩",
"    ♪   | ノ ⌒  ⌒ヽハッ    __ _,, -ー ,,    ハッ   / ⌒  ⌒ 丶|",
"        /  (●)  (●)  ハッ   (/   \"つ`..,:  ハッ (●)  (●) 丶     今、どんな気持ち?",
"       |     ( _●_) ミ    :/       :::::i:.   ミ (_●_ )    |        ねぇ、どんな気持ち?",
" ___ 彡     |∪| ミ    :i        ─::!,,    ミ、 |∪|    、彡____",
" ヽ___       ヽノ、`\     ヽ.....:::::::::  ::::ij(_::●   / ヽノ     ___/",
"       /       /ヽ <   r \"     .r ミノ~.    〉 /\    丶",
"      /      /    ̄   :|::|    ::::| :::i ゚。     ̄♪   \    丶",
"     /     /    ♪    :|::|    ::::| :::|:            \   丶",
"     (_ ⌒丶...        :` |    ::::| :::|_:           /⌒_)",
"      | /ヽ }.          :.,'    ::(  :::}            } ヘ /",
"        し  )).         ::i      `.-‐\"             J´((",
"          ソ  トントン                             ソ  トントン",
]; // }}}
const aaRowsNum = aa.length;
const aaColsNum = (function() {
var max = 0;
aa.forEach(function(text) { max = Math.max(max, text.length); });
return max;
})();
aa = aa.join("\n");
function pingTaichi () {
var elms = document.getElementsByTagName('textarea');
if(elms.length != 0) {
for(i = 0; i < elms.length; i++ ) {
var elm = elms[i];
if(elm.getAttribute('placeholder') === '今どんな気持ち?') {
elm.setAttribute('placeholder', aa);
elm.value = aa;
// (Maybe) height of Japanese characters are 2~3 times 'x'.
elm.style.height= (aaRowsNum * 3).toString() + 'ex';
elm.style.fontFamily='MS Pゴシック';
elm.style.fontSize='90%'; // [FIXME] Get perfect font size.
}
}
}
}
setInterval(pingTaichi, 300);
})();
@AmaiSaeta
Copy link
Author

@noromanba
Copy link

@AmaiSaeta
nice hack 👍

FYI
font-family

IPA mona font commonly used for cross-platform AA font in Japan.

MSPGothic => IPAMonaPGothic

font-size

// [FIXME] Get perfect font size.

What's the meaning of perfect?

Do you want to do it this way? e.g.

var size = getComputedStyle(elm, '').fontSize;
size = size ...; // font size control based on real size
elm.style.fontSize = size;

c.f. window.getComputedStyle - Document Object Model (DOM) | MDN


or want to override? e.g.

elm.style.fontSize='90% !important'; // append "!important" declaration
:)

Regards,
noromanba

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