Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Chrome Extension Added #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ $ ./bin/shaaaaaaaaaaaaa bad-domain
}
```

##Shaaaaaaaaaaaaa Chrome Extension
Version one. [Available on Chrome Web Store](https://chrome.google.com/webstore/detail/check-ssl/adlogjmkkcancjpododcnjndnmkooghi) for download.

## Author

Expand Down
39 changes: 39 additions & 0 deletions chrome-extension/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function formatURL() {
var currURL = window.location.host;
var url = currURL;
// remove 'www'
if (currURL.indexOf("www") >= 0){
url = currURL.split("www.")[1];
}
// remove any path after web address
if(window.location.pathname !== "/") {
var pathname = window.location.pathname;
url = url.split(pathname)[0];
}
return url;
}

function sendRequest(url) {
var xhr = new XMLHttpRequest();
xhr.open("GET", ("https://shaaaaaaaaaaaaa.com/api/check/" + url), true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var resp = JSON.parse(xhr.responseText);
var diagnosis = resp.diagnosis;
switch (diagnosis) {
case "good":
chrome.runtime.sendMessage({diagnosis: "good"});
break;
case "almost":
chrome.runtime.sendMessage({diagnosis: "almost"});
break;
case "bad":
chrome.runtime.sendMessage({diagnosis: "bad"});
break;
}
}
}
xhr.send();
}

sendRequest(formatURL());
27 changes: 27 additions & 0 deletions chrome-extension/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//listens for tab change
chrome.tabs.onActivated.addListener(function() {
chrome.browserAction.setBadgeBackgroundColor({color: [255,0,0,255]});
chrome.tabs.executeScript({file: "app.js"}, function() {
//on error - log error message and set badge to transparent
if (chrome.runtime.lastError) {
chrome.browserAction.setBadgeBackgroundColor({color: [0,0,0,0]});
chrome.browserAction.setBadgeText({text: ""});
console.error(chrome.runtime.lastError.message);
}
});
});


chrome.runtime.onMessage.addListener(
function(request, sender) {
//log diagnosis to badge
if (request.diagnosis == "bad") {
chrome.browserAction.setBadgeText({text: "bad"});
}
if (request.diagnosis == "almost") {
chrome.browserAction.setBadgeText({text: "almost"});
}
if (request.diagnosis == "good") {
chrome.browserAction.setBadgeText({text: "good"});
}
});
Binary file added chrome-extension/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"manifest_version": 2,
"name": "Shaaaaaaaaaaaaa Chrome Extension",
"short_name": "Check SSL",
"description": "Checks if websites have weak SHA-1 SSL certificates.",
"version": "1.0",
"permissions": [
"https://*/",
"http://*/",
"https://shaaaaaaaaaaaaa.com/api/check/*",
"tabs"
],
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["app.js"]
}
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_icon": "icon.png"
},
"web_accessible_resources": ["https://shaaaaaaaaaaaaa.com/api/check/*"]
}