Skip to content

Commit

Permalink
Rewrite localization system & Update icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitrrine committed Jun 19, 2024
1 parent 3e32088 commit f2dc87a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ chrome.runtime.onMessage.addListener((message, _, sendResponse) => {
})

let lastNavUrl = ""
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// If URL is empty, skip
if (!tab.url) return

Expand Down
36 changes: 25 additions & 11 deletions html/alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<title>Alert - Dangerous website was blocked!</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<style>
:root {
--primary: #e43232;
}

* {
box-sizing: border-box;
margin: 0;
Expand Down Expand Up @@ -48,16 +52,16 @@
display: flex;
align-items: center;
gap: 0.3em;
color: #e43232;
color: var(--primary);
font-size: 2em;
}

b {
color: #e43232;
color: var(--primary);
}

.details {
border: 1px solid #e43232;
border: 1px solid var(--primary);
padding: 1em;
}

Expand All @@ -77,7 +81,7 @@
.btn.secondary {
color: #fff;
background: transparent;
border: 1px #e43232 solid;
border: 1px var(--primary) solid;
}

.btn:hover {
Expand Down Expand Up @@ -116,27 +120,37 @@ <h1>
<path d="M12 9v4" />
<path d="M12 17h.01" />
</svg>
<div id="translated-alert">Alert</div>
<div translate-key="title">Alert</div>
</h1>
<p id="translated-description">
<p translate-key="description">
The website that you have tried to visit was blocked by
<b>StopMalwareContent</b> because it was found in our list and was
flagged as harmful or potentionally unwanted. Continue at your own risk
as this may harm your computer.
</p>
<div class="details">
<p>
<span id="translated-blocked">Blocked:</span> <b id="domain"></b
<span translate-key="blocked">Blocked:</span> <b id="domain"></b
><b id="path"></b>
</p>
<p><span id="translated-reason">Reason:</span> <b id="reason"></b></p>
<p><span id="translated-notes">Notes:</span> <b id="notes"></b></p>
<p><span translate-key="reason">Reason:</span> <b id="reason"></b></p>
<p><span translate-key="notes">Notes:</span> <b id="notes"></b></p>
</div>
<div class="actions">
<button class="btn secondary" id="ignore" tabindex="2">
<button
translate-key="accept_the_risk"
class="btn secondary"
id="ignore"
tabindex="2"
>
Accept the risk
</button>
<button class="btn primary" id="back" tabindex="1">
<button
translate-key="back_to_safety"
class="btn primary"
id="back"
tabindex="1"
>
Back to safety
</button>
</div>
Expand Down
23 changes: 9 additions & 14 deletions html/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ fetch("./locales.json")
.then((response) => response.json())
.then((data) => {
if (data[preferedLanguage]) {
document.getElementById("translated-alert").innerHTML =
data[preferedLanguage].title
document.getElementById("translated-description").innerHTML =
data[preferedLanguage].description
document.getElementById("translated-blocked").innerText =
data[preferedLanguage].blocked
document.getElementById("translated-reason").innerText =
data[preferedLanguage].reason
document.getElementById("translated-notes").innerText =
data[preferedLanguage].notes
document.getElementById("ignore").innerText =
data[preferedLanguage].accept_the_risk
document.getElementById("back").innerText =
data[preferedLanguage].back_to_safety
var elements = document.getElementsByTagName("*")

for (let i = 0; i < elements.length; i++) {
const element = elements[i]
let translateKey = element.getAttribute("translate-key")
if (translateKey) {
element.innerHTML = data[preferedLanguage][translateKey]
}
}
}
})
.catch((error) => console.log(error))
Expand Down
Binary file modified icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"manifest_version": 3,
"name": "Stop Malware Content",
"version": "1.3.6",
"version": "1.3.7",

"description": "Restricts access to harmful or unwanted web resources.",

"developer": {
"name": "Lodine Software",
"url": "https://stopmalwarecontent.lodine.xyz"
},

"icons": {
"48": "icons/icon.png",
"96": "icons/[email protected]",
Expand Down

0 comments on commit f2dc87a

Please sign in to comment.