Skip to content

Instantly share code, notes, and snippets.

@pacochi
pacochi / hb_mp3_audio.js
Last active February 12, 2017 12:59
はてなブログで [http://~.mp3:sound] と書いた時に出るプレイヤーを優しくします。
(function() {
// モバイル端末で viewport がいい具合に設定されてないと FastClick が発動して AUDIO 要素をタップできなくなる
if (!document.querySelector('meta[name="viewport"]')) {
var viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
viewport.setAttribute('content', 'width=device-width,initial-scale=1.0');
document.querySelector('head').appendChild(viewport);
}
@pacochi
pacochi / hb_mml_player.js
Created May 25, 2016 13:44
はてなブログで MML プレイヤーを出します。
// 元のは Ten.js ないと動かなかった & d.hatena.ne.jp でしか読み込めなかった
(function() {
if (typeof(Hatena) == 'undefined') Hatena = {};
if (typeof(Hatena.MMLPlayer) == 'function') return;
var hatenaD = 'http://d.hatena.ne.jp/images/';
var buttonCSS = { 'cursor': 'pointer', 'margin-right': '4px' };
Hatena.MMLPlayer = function(mmlCode) {
@pacochi
pacochi / hatenablog_q_cite_expander.js
Last active February 12, 2017 13:01
はてなブログで q 要素の cite 属性を展開します。
/*
http://hatenadiary.g.hatena.ne.jp/keyword/%E5%BC%95%E7%94%A8%E5%85%83%E3%82%B5%E3%82%A4%E3%83%88%E3%82%92%E8%87%AA%E5%8B%95%E7%9A%84%E3%81%AB%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%EF%BC%88cite%E3%80%81title%E5%B1%9E%E6%80%A7%EF%BC%89
q の cite がはてなブログで展開されないので書きました。
*/
document.addEventListener('DOMContentLoaded', function() {
Array.prototype.forEach.call(document.querySelectorAll('q[cite]'), function(node) {
var cite = document.createElement('cite');
var a = document.createElement('a');
a.setAttribute('href', node.getAttribute('cite'));
@pacochi
pacochi / JP106Key.php
Created May 23, 2011 02:57
間違った入力モードで入力された文を読みやすくするクラス
<?php
# 宇宙語・みかか語変換
# ぺたちゃ用に作りました
# UTF-8 向けです
/*
mb_internal_encoding('UTF-8');
require_once('./JP106Key.php');