From 42dcdb40cf16f23abd90a7511de0bf5991ecdba0 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sat, 24 Aug 2019 18:06:25 +0100 Subject: [PATCH] Added localizeHtmlPage --- utils.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index 5fa60564..a654e03a 100644 --- a/utils.js +++ b/utils.js @@ -38,4 +38,25 @@ function getYouTubeVideoID(url) { } } return false; -} \ No newline at end of file +} + +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; + } + } +}