Sorry, there are no scripts tagged war;msg6173

Internet Archive - Correct character set

By brasil Last update Jun 2, 2007 — Installed 812 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 3, 0, 0
// ==UserScript==
// @name       Internet Archive - Correct character set
// @namespace  http://userscripts.org/users/7010
// @include    http://web.archive.org/web/*
// ==/UserScript==

try{
	var contentCharSet = l(getCharSet());
	if( contentCharSet && contentCharSet != l(document.characterSet))
		correctCharSet();
} catch(e){}

function getCharSet(){
	return getContentType().match(/charset=(.*)/) ? 
		RegExp.$1 : '';
}

function getContentType(){
	for(var i=0, metas=document.getElementsByTagName("meta") ; i<metas.length ; i++)
		if(l(metas[i].httpEquiv) == "content-type")
			return metas[i].content;
	
	return '';
}

function correctCharSet(){
	GM_xmlhttpRequest({
		method : 'GET', 
		overrideMimeType : getContentType(),
		url : location.href, 
		onload : function(res){
			document.body.innerHTML = res.responseText;
			
			var titles = document.getElementsByTagName('title');
			titles && (document.title = titles[titles.length - 1].textContent);
		}
	})
}

function l(s){return s && s.toLowerCase()}