Added localizeHtmlPage

This commit is contained in:
Official Noob 2019-08-24 18:06:25 +01:00 committed by GitHub
parent 7244ca8f5e
commit 42dcdb40cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,4 +38,25 @@ function getYouTubeVideoID(url) {
}
}
return false;
}
}
function localizeHtmlPage()
{
//Localize by replacing __MSG_***__ meta tags
var objects = document.getElementsByTagName('html');
for (var j = 0; j < objects.length; j++)
{
var obj = objects[j];
var valStrH = obj.innerHTML.toString();
var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function(match, v1)
{
return v1 ? chrome.i18n.getMessage(v1) : "";
});
if(valNewH != valStrH)
{
obj.innerHTML = valNewH;
}
}
}