0
I have this code in manifest.json:
{ "manifest_version": 2, "version":"0.0.1", "name":"Checador de Protocolo", "description":"verifique se o site e seguro ou não", "author":"Nick1", "icons": { "128": "128.png" }, "browser_action":{ "default_title":"Checador de Protocolo", "default_popup":"index.html" }, "permissions": [ "tabs" ] }
and this html code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Extesion</title>
<script src="script.js"></script>
</head>
<body>
<img src="assets/img/logo.png" class="logo"/><br><hr><br>
<h1 id="HTTPID">...</h1>
</body>
</html>
and finally the script.js:
chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
let url = tabs[0].url;
var TabProtocol = tabs[0];
var UrlHost = new URL(TabProtocol.url)
var DomainProtocol = UrlHost.protocol;
if (DomainProtocol == "https:") {
document.getElementById("HTTPID").innerHTML ="<svg aria-hidden='true' focusable='false' data-prefix='fas' data-icon='lock' class='svg-inline--fa fa-lock fa-w-14' role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path fill='currentColor' d='M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z'></path></svg>"+" "+"Seguro";
}
else{
document.getElementById("HTTPID").innerHTML ="<svg aria-hidden='true' focusable='false' data-prefix='fas' data-icon='exclamation-triangle' class='svg-inline--fa fa-exclamation-triangle fa-w-18' role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'><path fill='currentColor' d='M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z'></path></svg>"+ " "+"Não Seguro";
}});
as you can see, it does a protocol check following this line, as I could add a line to Else that opens the pop-up automatically if the site is not safe?