標準準拠モードでレンダリングさせないようなWebページの右肩に輝かしいアナログの文字を表示するだけのUser JavaScriptを書いた。ちなみに使っているフォントは丸ゴシック体Ca-U。
// ==UserScript==
// @name Analog Web
// @description Show "Analog" letters on right-top of the web page that is rendered by Quirks mode.
// @version 0.3
// @namespace http://kuruman.org/
// @include http://*
// ==/UserScript==
var ANALOG_COLOR = '#c0c0c0';
var OPACITY = '.2';
document.addEventListener('DOMContentLoaded',function(){
if (document.compatMode != 'CSS1Compat') {
var img = document.createElement('img');
img.setAttribute('src','data:image/svg+xml,<?xml version="1.0"?><svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="300" height="100"><path d="M 62.369385,17.124813 C 62.369319,21.084329 61.754452,24.504369 60.52478,27.384944 C 59.294982,30.265594 57.704895,32.710782 55.754517,34.72052 C 53.80402,36.73031 51.763861,38.36507 49.634033,39.62481 C 47.5041,40.8846 45.3896,41.93489 43.290527,42.77569 C 39.749957,44.09554 37.289755,43.16536 35.909912,39.98516 C 35.309288,38.48519 35.234215,37.15035 35.684692,35.98065 C 36.135093,34.811 37.259725,33.925869 39.058594,33.325252 C 40.439898,32.784757 41.925248,32.06442 43.514648,31.164241 C 45.103956,30.264129 46.528881,29.229218 47.789429,28.059505 C 49.049875,26.889865 50.070137,25.540013 50.85022,24.009944 C 51.630194,22.479957 52.020209,21.175149 52.020264,20.095516 C 52.020209,19.015971 51.509711,18.476177 50.48877,18.476131 L 5.220703,18.476131 C 1.74023,18.476177 -3e-06,16.796003 3.5527137e-15,13.435604 C -3e-06,10.195424 1.74023,8.5753085 5.220703,8.5752525 L 53.729736,8.5752525 C 59.489439,8.5753085 62.369319,11.425159 62.369385,17.124813 L 62.369385,17.124813 z M 23.668945,27.115779 C 23.668919,23.575293 25.46921,21.805031 29.069824,21.804988 C 32.550257,21.805031 34.29049,23.575293 34.290527,27.115779 C 34.29049,35.63534 34.155358,41.45516 33.885132,44.57525 C 33.614832,47.69539 32.879847,50.59028 31.680176,53.25994 C 30.480435,55.92963 28.515349,58.43451 25.784912,60.77459 C 23.054417,63.11468 19.349099,65.0047 14.668945,66.44464 C 11.129869,67.46563 8.730457,66.29595 7.470703,62.9356 C 6.32958,59.63532 7.559316,57.47541 11.159912,56.45587 C 14.400129,55.49494 16.859965,54.32453 18.539429,52.94464 C 20.218849,51.56477 21.418921,49.97505 22.139648,48.17547 C 22.860326,46.37593 23.295384,44.21602 23.444824,41.69574 C 23.594212,39.1755 23.668919,34.31552 23.668945,27.115779 L 23.668945,27.115779 z M 98.171629,20.904109 L 98.171629,8.6653405 C 98.171599,5.1849315 99.941129,3.4446985 103.48023,3.4446375 C 107.02071,3.4446985 108.79097,5.1849315 108.79102,8.6653405 L 108.79102,20.904109 L 127.15137,20.904109 C 130.69183,20.904153 132.46209,22.524269 132.46216,25.764461 C 132.46209,29.004731 130.69183,30.624847 127.15137,30.624813 L 108.79102,30.624813 C 108.79097,35.66537 108.64119,39.64058 108.34168,42.55047 C 108.04207,45.4604 107.18697,48.61018 105.77637,51.99981 C 104.36568,55.38947 101.98055,58.44953 98.620969,61.17999 C 95.261319,63.91046 90.341279,65.81549 83.860839,66.89508 C 79.961409,67.49566 77.681379,66.20587 77.020749,63.02569 C 76.241439,59.54523 77.741439,57.5047 81.520749,56.90411 C 86.020729,56.18488 89.380709,54.92512 91.600709,53.12481 C 93.820649,51.32453 95.365689,49.25434 96.235839,46.91424 C 97.105929,44.57417 97.646089,42.30916 97.856319,40.1192 C 98.066499,37.92928 98.171599,34.76449 98.171629,30.624813 L 72.971191,30.624813 C 69.43066,30.624847 67.660398,29.004731 67.6604,25.764461 C 67.660398,22.524269 69.43066,20.904153 72.971191,20.904109 L 98.171629,20.904109 z M 190.57984,8.5752525 C 196.15936,8.5753085 198.94916,11.3651 198.94922,16.944637 L 198.94922,54.7442 C 198.94916,60.32526 196.15936,63.11578 190.57984,63.11578 L 149.89966,63.11578 C 144.38012,63.11578 141.62036,60.32526 141.62036,54.7442 L 141.62036,16.944637 C 141.62036,11.3651 144.38012,8.5753085 149.89966,8.5752525 L 190.57984,8.5752525 z M 152.32984,51.6856 C 152.32982,52.70515 152.83958,53.21491 153.85913,53.2149 L 186.71045,53.2149 C 187.72993,53.21491 188.23969,52.70515 188.23975,51.6856 L 188.23975,20.005428 C 188.23969,18.985942 187.72993,18.476177 186.71045,18.476131 L 153.85913,18.476131 C 152.83958,18.476177 152.32982,18.985942 152.32984,20.005428 L 152.32984,51.6856 z M 235.39966,21.804988 C 233.71946,24.504736 231.27427,27.339572 228.06409,30.309505 C 224.85386,33.279507 221.38915,35.63461 217.66992,37.37481 C 214.18945,38.99496 211.66919,38.06478 210.10913,34.58429 C 208.72925,31.644377 209.68945,29.454438 212.98975,28.014461 C 217.2495,26.035496 220.84935,23.320777 223.78931,19.870296 C 226.72923,16.419905 229.09934,12.504748 230.89966,8.1248135 C 232.03928,4.7645215 234.43943,3.5948445 238.1001,4.6157795 C 241.99948,5.6954285 243.16915,7.7952805 241.60913,10.91534 C 241.36886,11.335803 241.15939,11.665393 240.98071,11.904109 L 260.51001,11.904109 C 260.14961,10.884632 259.78962,9.9398095 259.43005,9.0696375 C 259.07038,8.1995765 258.68037,7.3448415 258.26001,6.5054285 C 257.06025,3.8057825 257.81025,2.0355205 260.51001,1.1946375 C 261.34931,0.95446646 262.1894,0.92443746 263.03027,1.1045495 C 264.04975,1.2847885 264.91986,2.2149635 265.64063,3.8950765 C 266.11957,4.9146675 266.55426,5.9195495 266.9447,6.9097255 C 267.33502,7.9000165 267.6203,8.7847815 267.80054,9.5640225 C 268.04071,10.464955 268.10077,11.21532 267.98071,11.81512 C 267.86054,12.415026 267.50018,12.80504 266.89966,12.985164 C 268.88007,14.24498 269.8703,16.494978 269.87036,19.735164 C 269.8703,24.41538 268.89508,29.485566 266.9447,34.94574 C 264.99421,40.40596 262.02424,45.53584 258.03479,50.33538 C 254.04524,55.13495 248.79525,59.1098 242.28479,62.25994 C 235.77426,65.41009 227.6594,67.43487 217.94019,68.33429 C 214.15942,68.75469 212.05957,67.22466 211.64063,63.7442 C 211.22021,60.20514 212.8103,58.28546 216.41089,57.98516 C 225.17064,57.14582 232.08542,55.57111 237.15527,53.26104 C 242.22506,50.951 246.25997,47.96565 249.26001,44.30499 C 252.25996,40.64437 254.61507,36.77425 256.32532,32.694637 C 258.03547,28.615083 258.89057,25.404881 258.89063,23.064022 C 258.89057,22.224709 258.44013,21.805031 257.53931,21.804988 L 235.39966,21.804988 z M 268.33887,5.5144615 C 267.1391,2.8148165 267.8891,1.0452865 270.58887,0.20586746 C 271.42962,-0.034301536 272.26971,-0.064331536 273.10913,0.11577946 C 274.13006,0.29602046 275.00018,1.2254625 275.71948,2.9041095 C 276.19988,3.9251665 276.63494,4.9304145 277.02466,5.9198575 C 277.41424,6.9094165 277.69915,7.7945475 277.8794,8.5752525 C 278.11956,9.5948385 278.11956,10.464955 277.8794,11.185604 C 277.57903,12.145129 276.73894,12.80504 275.35913,13.16534 C 272.5993,13.944687 270.88983,13.014513 270.23071,10.374813 C 269.99042,9.5355125 269.70514,8.7108065 269.37488,7.9006915 C 269.04449,7.0906905 268.69916,6.2952815 268.33887,5.5144615 L 268.33887,5.5144615 z" style="fill:'+ANALOG_COLOR+';fill-opacity:1;stroke:none"/></svg>');
img.setAttribute('alt','アナログ');
img.setAttribute('style','opacity:'+OPACITY+';position:fixed;top:10px;right:10px;width:100px;max-width:20%;z-index:9999999999');
document.body.appendChild(img);
}
},false);
で、久しぶりにMyOperaへアップロードしたのだけれど、いつの間にかファイルのダウンロード時に警告が促され、リファラを送信しない限りダウンロードできなくなっていた。良いことだとは思うけど、面倒。……面倒な人向けにソースコードくらい貼り付けることにした。
当初は読み込まれると同時に匿名関数として実行していたのだけれど、browser.jsが働く一部のページではそのようなUser JavaScriptがDOM構築完了前(補註: すなわちdocument.body
がnull
)の時点で実行されてしまうようだ。そんなケースを発見したのでこのUser JavaScriptの実行タイミングを明示した。