Add settings page
This commit is contained in:
		@@ -1,10 +1,11 @@
 | 
			
		||||
{
 | 
			
		||||
  "manifest_version": 2,
 | 
			
		||||
  "name": "HTTPS+ Checker",
 | 
			
		||||
  "version": "0.0.2",
 | 
			
		||||
  "version": "0.0.3",
 | 
			
		||||
  "description": "Verification of security mechanisms complementary to HTTPS",
 | 
			
		||||
  "permissions": [
 | 
			
		||||
    "tabs",
 | 
			
		||||
    "storage",
 | 
			
		||||
    "webRequest",
 | 
			
		||||
    "<all_urls>"
 | 
			
		||||
  ],
 | 
			
		||||
@@ -20,5 +21,8 @@
 | 
			
		||||
  "icons": {
 | 
			
		||||
      "48": "icon_x48.png",
 | 
			
		||||
      "96": "icon_x96.png"
 | 
			
		||||
  },
 | 
			
		||||
  "options_ui": {
 | 
			
		||||
    "page": "settings/options.html"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,21 @@
 | 
			
		||||
 | 
			
		||||
var xhr = new XMLHttpRequest();
 | 
			
		||||
 | 
			
		||||
function onGot(item) {
 | 
			
		||||
  var API = "http://httpspluschecker.virtit.fr/?domain=";
 | 
			
		||||
  if (item.API) {
 | 
			
		||||
    API = item.API;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
browser.tabs.query({ active: true, lastFocusedWindow: true }).then(function(tab) {
 | 
			
		||||
    const url = new URL(tab[0].url);
 | 
			
		||||
    if (url.protocol === "http:" || url.protocol === "https:" ) {
 | 
			
		||||
	    console.log("onGot : " + API)
 | 
			
		||||
	    var host = url.hostname ;
 | 
			
		||||
 | 
			
		||||
	    xhr.open('GET', 'https://httpspluschecker.virtit.fr/?domain=' + host, false);
 | 
			
		||||
	    xhr.open('GET', API + host, false);
 | 
			
		||||
		xhr.send();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		value = JSON.parse(xhr.responseText);
 | 
			
		||||
 | 
			
		||||
		if (value['DNSSEC'] === true  ) {
 | 
			
		||||
@@ -35,3 +41,9 @@ browser.tabs.query({ active: true, lastFocusedWindow: true }).then(function(tab)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
var getting = browser.storage.local.get("API");
 | 
			
		||||
getting.then(onGot);
 | 
			
		||||
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="utf-8">
 | 
			
		||||
    <link rel="stylesheet" href=" style.css">
 | 
			
		||||
    <script type="text/javascript" src="dnssec.js"></script>
 | 
			
		||||
    <script type="text/javascript" src="checks.js"></script>
 | 
			
		||||
  </head>
 | 
			
		||||
 | 
			
		||||
  <body>
 | 
			
		||||
@@ -18,4 +18,4 @@
 | 
			
		||||
      </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
  </body>
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
@@ -28,4 +28,4 @@ td {
 | 
			
		||||
  text-align: center;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  font-size: 18px;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								settings/options.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								settings/options.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
<html>
 | 
			
		||||
  <head>
 | 
			
		||||
	<meta charset="utf-8">
 | 
			
		||||
	<style>
 | 
			
		||||
		input[type=text], select {
 | 
			
		||||
			width: 70%;
 | 
			
		||||
		}
 | 
			
		||||
		.buttons {
 | 
			
		||||
			display: inline-block;
 | 
			
		||||
		}
 | 
			
		||||
	</style>
 | 
			
		||||
  </head>
 | 
			
		||||
  <div class="buttons">
 | 
			
		||||
<a href="https://git.virtit.fr/VirtIT/wext-httpspluschecker"><button>Source of the Extension</button></a>
 | 
			
		||||
<a href="https://git.virtit.fr/VirtIT/wext-httpspluschecker_api"><button>Source of the API</button></a>
 | 
			
		||||
  </div>
 | 
			
		||||
	  <form>
 | 
			
		||||
	    <label>API URL :<br><input type="text" id="API" ></label>
 | 
			
		||||
	<br>
 | 
			
		||||
        <button type="submit">Save</button>
 | 
			
		||||
    </form>
 | 
			
		||||
 | 
			
		||||
    <script src="options.js"></script>
 | 
			
		||||
 | 
			
		||||
  </body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										23
									
								
								settings/options.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								settings/options.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
function saveOptions(e) {
 | 
			
		||||
  e.preventDefault();
 | 
			
		||||
  browser.storage.local.set({
 | 
			
		||||
    API: document.querySelector("#API").value
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function restoreOptions() {
 | 
			
		||||
 | 
			
		||||
  function setCurrentChoice(result) {
 | 
			
		||||
    document.querySelector("#API").value = result.API || "http://httpspluschecker.virtit.fr/?domain="  ;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function onError(error) {
 | 
			
		||||
    console.log(`Error: ${error}`);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  var getting = browser.storage.local.get("API");
 | 
			
		||||
  getting.then(setCurrentChoice, onError);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
document.addEventListener("DOMContentLoaded", restoreOptions);
 | 
			
		||||
document.querySelector("form").addEventListener("submit", saveOptions);
 | 
			
		||||
		Reference in New Issue
	
	Block a user