RFCをプリントアウトして読みたい事がある。ただ、IETF上のRFCはテキストファイルのため、ブラウザ上から印刷する場合、レイアウトが崩れてしまう。あまりにも面倒なので、RFCをレイアウトし直すBookmarkletを作成した。
対象ブラウザはFirefoxのみとなっている。A4サイズぎりぎりのため、余白の調整が必要だ。
また、他サイト上のRFCはレイアウトし直されている可能性があるため、IETF上のRFCでのみ動作するように制限をかけている。
対象ブラウザはFirefoxのみとなっている。A4サイズぎりぎりのため、余白の調整が必要だ。
また、他サイト上のRFCはレイアウトし直されている可能性があるため、IETF上のRFCでのみ動作するように制限をかけている。
/*
================================================================================
Name : IETF上のRFCを印刷しやすくするBookmarklet Ver1.0.1
In : [none]
Out : [none]
Note : IETF上のRFCを印刷向きに再レイアウトします。
--------------------------------------------------------------------------------
Version : Ver1.0.0 | 2007/03/17 | 新規作成
: Ver1.0.1 | 2007/03/17 | ページ分割処理を修正
--------------------------------------------------------------------------------
License : MIT license
URL : www.kanasansoft.com
================================================================================
*/
(
function(){
if((/^http:\/\/www\.ietf\.org\/rfc\/rfc[0-9]{4}\.txt$/).test(location.href)){
var
d = window.document
,p = d.getElementsByTagName("pre")[0]
,c = p.textContent?true:false
,s = (c?p.textContent:p.innerText).split("\f")
,b = d.getElementsByTagName("body")[0]
,i
,q
,r
;
while(b.hasChildNodes()){
b.removeChild(b.firstChild)
}
for(var i=0;i<s.length;i++){
q = d.createElement("pre");
with(q.style){
width = "7.5in";
height = "10.75in";
borderWidth = "0in";
padding = "0in";
margin = "auto";
fontSize = "14pt";
fontFamily = "monospace";
lineHeight = "14pt";
pageBreakAfter = "always";
pageBreakInside = "avoid";
}
r = s[i] .
replace( /^\n/ig , "" ) .
replace( /[ \n]+$/ig , "" ) .
split( "\n" ) .
slice( -55 ) .
join( "\n" ) ;
if(r!=""){
if(c){
q.textContent = r
}else{
q.innerText = r
}
b.appendChild(q)
}
}
}else{
alert("don\'t match \n[RFC] of IETF site")
}
}
)
()
================================================================================
Name : IETF上のRFCを印刷しやすくするBookmarklet Ver1.0.1
In : [none]
Out : [none]
Note : IETF上のRFCを印刷向きに再レイアウトします。
--------------------------------------------------------------------------------
Version : Ver1.0.0 | 2007/03/17 | 新規作成
: Ver1.0.1 | 2007/03/17 | ページ分割処理を修正
--------------------------------------------------------------------------------
License : MIT license
URL : www.kanasansoft.com
================================================================================
*/
(
function(){
if((/^http:\/\/www\.ietf\.org\/rfc\/rfc[0-9]{4}\.txt$/).test(location.href)){
var
d = window.document
,p = d.getElementsByTagName("pre")[0]
,c = p.textContent?true:false
,s = (c?p.textContent:p.innerText).split("\f")
,b = d.getElementsByTagName("body")[0]
,i
,q
,r
;
while(b.hasChildNodes()){
b.removeChild(b.firstChild)
}
for(var i=0;i<s.length;i++){
q = d.createElement("pre");
with(q.style){
width = "7.5in";
height = "10.75in";
borderWidth = "0in";
padding = "0in";
margin = "auto";
fontSize = "14pt";
fontFamily = "monospace";
lineHeight = "14pt";
pageBreakAfter = "always";
pageBreakInside = "avoid";
}
r = s[i] .
replace( /^\n/ig , "" ) .
replace( /[ \n]+$/ig , "" ) .
split( "\n" ) .
slice( -55 ) .
join( "\n" ) ;
if(r!=""){
if(c){
q.textContent = r
}else{
q.innerText = r
}
b.appendChild(q)
}
}
}else{
alert("don\'t match \n[RFC] of IETF site")
}
}
)
()