浏览代码

Popup Configuration

The popup.html and popup.js are configured
Fernando Dilland Mireles Cisneros 3 年之前
父节点
当前提交
0c45be3c0b
共有 2 个文件被更改,包括 38 次插入16 次删除
  1. 13 13
      Extensions/combined/popup.html
  2. 25 3
      Extensions/combined/popup.js

+ 13 - 13
Extensions/combined/popup.html

@@ -1,8 +1,8 @@
 <!DOCTYPE html>
-<html lang="en">
+<html>
   <head>
     <meta content="text/html; charset=utf-8" />
-    <title>Return YouTube Dislike</title>
+    <title title="__MSG_extensionName__">__MSG_extensionName__</title>
     <link rel="stylesheet" href="popup.css" />
     <link rel="preconnect" href="https://fonts.googleapis.com" />
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
@@ -20,16 +20,16 @@
         />
         <path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff" />
       </svg>
-      <h1 style="margin-bottom: 0.75rem">Return YouTube Dislike</h1>
-      <p style="color: var(--lightGrey)">by Dmitrii Selivanov & Community</p>
+      <h1 style="margin-bottom: 0.75rem" title="__MSG_extensionName__">__MSG_extensionName__</h1>
+      <p style="color: var(--lightGrey)" title="__MSG_textDeveloper__">__MSG_textDeveloper__</p>
 
-      <button id="link_website">Website</button>
-      <button id="link_github">GitHub</button>
+      <button id="link_website" title="__MSG_linkWebsite__">__MSG_linkWebsite__</button>
+      <button id="link_github" >GitHub</button>
       <button id="link_discord">Discord</button>
       <br />
-      <button style="margin-top: 0.3rem" id="link_faq">FAQ</button>
-      <button style="margin-top: 0.3em" id="link_donate">Donate</button>
-      <button style="margin-top: 0.3em" id="link_help">Help</button>
+      <button style="margin-top: 0.3rem" id="link_faq" title="__MSG_linkFAQ__">__MSG_linkFAQ__</button>
+      <button style="margin-top: 0.3em" id="link_donate" title="__MSG_linkDonate__">__MSG_linkDonate__</button>
+      <button style="margin-top: 0.3em" id="link_help" title="__MSG_linkHelp__">__MSG_linkHelp__</button>
 
       <br />
       <br />
@@ -40,7 +40,7 @@
         src="./icons/server.svg"
         alt=""
       />
-      
+
       <br />
       <br />
     </center>
@@ -70,12 +70,12 @@
 
     <!-- dialog box -->
     <fieldset id="advancedSettings">
-      <legend id="advancedLegend">Settings</legend>
+      <legend id="advancedLegend" title="__MSG_legendSettings__">__MSG_legendSettings__</legend>
 
-      <label class="switch" data-hover="Stops counting your likes and dislikes.">
+      <label class="switch" data-hover="__MSG_textSettingsHover__">
         <input type="checkbox" id="disable_vote_submission" />
         <span class="slider" />
-        <span class="switchLabel">Disable vote submission</span>
+        <span class="switchLabel" title="__MSG_textSettings__">__MSG_textSettings__</span>
       </label>
       <!-- <br />
       <label class="switch">

+ 25 - 3
Extensions/combined/popup.js

@@ -2,7 +2,7 @@
 const config = {
   advanced: false,
   disableVoteSubmission: false,
-  
+
   showAdvancedMessage: '<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><rect fill="none" height="24" width="24"/><path d="M19.5,12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3,0.51-0.86,0.26-1.3l-1.87-3.23c-0.25-0.44-0.79-0.62-1.25-0.42 l-2.15,0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8,2.38,14.37,2,13.87,2h-3.73C9.63,2,9.2,2.38,9.14,2.88L8.85,5.19 c-0.41,0.19-0.8,0.42-1.17,0.68L5.53,4.96c-0.46-0.2-1-0.02-1.25,0.42L2.41,8.62c-0.25,0.44-0.14,0.99,0.26,1.3l1.86,1.41 C4.51,11.55,4.5,11.77,4.5,12s0.01,0.45,0.03,0.68l-1.86,1.41c-0.4,0.3-0.51,0.86-0.26,1.3l1.87,3.23c0.25,0.44,0.79,0.62,1.25,0.42 l2.15-0.91c0.37,0.26,0.76,0.49,1.17,0.68l0.29,2.31C9.2,21.62,9.63,22,10.13,22h3.73c0.5,0,0.93-0.38,0.99-0.88l0.29-2.31 c0.41-0.19,0.8-0.42,1.17-0.68l2.15,0.91c0.46,0.2,1,0.02,1.25-0.42l1.87-3.23c0.25-0.44,0.14-0.99-0.26-1.3l-1.86-1.41 C19.49,12.45,19.5,12.23,19.5,12z M12.04,15.5c-1.93,0-3.5-1.57-3.5-3.5s1.57-3.5,3.5-3.5s3.5,1.57,3.5,3.5S13.97,15.5,12.04,15.5z"/></svg>',
   hideAdvancedMessage: '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none" opacity=".87"/><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0-.39-.39-.39-1.02 0-1.41L10.59 12 7.7 9.11c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"/></svg>',
 
@@ -16,6 +16,29 @@ const config = {
   },
 };
 
+/*   Change lenguage   */
+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;
+        }
+    }
+}
+
+localizeHtmlPage();
 
 /*   Links   */
 createLink(config.links.website,"link_website")
@@ -72,7 +95,7 @@ function initializeVersionNumber() {
     .then((response) => response.json())
     .then((json) => {
       if (version !== json.version) {
-        document.getElementById('ext-update').innerHTML = 'update to v' + json.version;
+        document.getElementById('ext-update').innerHTML = chrome.i18n.getMessage("textUpdate") +' v' + json.version;
         document.getElementById('ext-update').style.padding = '.25rem .5rem';
       }
     });
@@ -121,7 +144,6 @@ function handleDisableVoteSubmissionChangeEvent(value) {
   }
 })();
 
-
 /* popup-script.js
 document.querySelector('#login')
 .addEventListener('click', function () {