/*
* @title aozora tategaki text-orientation: upright
* @include http://www.aozora.gr.jp/cards/*
* @require https://raw.github.com/necolas/normalize.css/master/normalize.css
*/
// 青空文庫 縦書き拡張 http://subtech.g.hatena.ne.jp/cho45/20110319/1300542682
// cf. https://gist.github.com/cho45/875989
// normalize.css https://github.com/necolas/normalize.css
// commentToText
// https://github.com/tombfix/core/blob/2b0f251ff7d5968a138e2a4e8d24d5947005826a/xpi/chrome/content/library/01_utility.js#L2489
var styles = document.styleSheets;
for (var i = 0, it; it = styles[i]; i++) {
it.disabled = true;
}
var css = commentToText(function () {/*
body {
font-family: serif;
font-size: 12pt;
line-height: 1.5em;
padding: 1em;
-webkit-writing-mode: vertical-rl;
writing-mode: vertical-rl;
-webkit-text-orientation: upright;
text-orientation: upright;
overflow-y:hidden;
text-align: justify;
letter-spacing: 0.1em;
}
a {
text-decoration:none;
pointer-events: none;
color:black;
}
rt {
display:none;
}
img {
max-height:100%;
}
*/});
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
document.querySelector('head').appendChild(style);
// bug for rendering ruby elements
document.body.innerHTML = document.body.innerHTML;
document.body.addEventListener('mousewheel', function (e) {
if (e.wheelDeltaX) {
document.body.scrollLeft -= e.wheelDeltaX;
} else {
document.body.scrollLeft += e.wheelDelta;
}
e.preventDefault();
}, false);
// commentToText via tombloo
function commentToText(commentFunc) {
return (commentFunc).toString().replace(/^.*?\r?\n/, '').replace(/\r?\n.*?$/, '');
}