View your submitted message<\/a>/ );
if ( matches )
{
editcontent.parentNode.removeChild( editcontent );
content.style.display = 'block';
content.innerHTML = 'Saving...
';
updatePost( matches[ 1 ].replace( /&/gi, '&' ), textarea, postbody, editcontent, content );
}
else
{
var matches = responseDetails.responseText.match( /([^<]+)<\/p>/i );
if ( matches )
alert( matches[ 1 ] );
}
},
});
}
function updatePost( posturl, textarea, postbody, editcontent, content )
{
posturl = location.href.replace( /^(.+)\/[^/]+$/, '$1' ) + posturl.replace( /^\./, '' );
var postid = posturl.replace( /^.+#([^#]+)$/, '$1' );
GM_xmlhttpRequest({
method: 'GET',
url: posturl,
onload:
function( responseDetails )
{
if ( responseDetails.status != 200 )
{
alert( 'Unable to retrieve quoted text: ' + responseDetails.statusText );
return;
}
var span = document.createElement( 'span' );
var html = responseDetails.responseText.replace( /[\r\n]+/gim, '' );
span.innerHTML = html.replace( /^.*
]+>(.+)<\/body>/i, '$1' );
var divs = span.getElementsByTagName( 'div' );
var authorNew = null;
var contentNew = null;
var noticeNew = null;
var postDiv = null;
for ( var i = 0; i < divs.length && ( contentNew == null || noticeNew == null ); i++ )
{
var div = divs[ i ];
if ( div.id == postid )
postDiv = div;
if ( postDiv == null )
continue;
if ( contentNew == null && div.getAttribute( "class" ) == 'content' )
contentNew = div;
if ( noticeNew == null && div.getAttribute( "class" ) == 'notice' )
noticeNew = div;
}
var divs = postbody.getElementsByTagName( 'div' );
var noticeUpdated = false;
for ( var i = 0; i < divs.length; i++ )
{
var div = divs[ i ];
if ( contentNew != null && div.getAttribute( "class" ) == 'content' )
div.innerHTML = contentNew.innerHTML;
if ( noticeNew != null && div.getAttribute( "class" ) == 'notice' )
{
div.innerHTML = noticeNew.innerHTML;
noticeUpdated = true;
}
}
if ( !noticeUpdated )
{
content.parentNode.insertBefore( noticeNew, content.nextSibling );
}
},
});
}
var html_entity_decode_ta = document.createElement( "textarea" );
function html_entity_decode( str )
{
html_entity_decode_ta.innerHTML = str.replace( //g, ">" );
return html_entity_decode_ta.value;
}
})();