Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitrrine committed Aug 29, 2024
1 parent 26cb646 commit ab6c796
Show file tree
Hide file tree
Showing 11 changed files with 2,223 additions and 908 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ contact_links:
about: If you think we should add a new website to the list, go here.
- name: Report a false-positive
url: https://github.com/StopMalwareContent/Site-Tracker/issues/new?assignees=Nitrrine&labels=website+remove&projects=&template=report-a-false-positive.md&title=Remove+%28url+goes+here%29+from+block+list
about: If a website is mislabeled in your opinion, report that here.
about: If a website is mislabeled in your opinion, report that here.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: "(put a title for your feature request here)"
labels: feature request
assignees: Nitrrine

---

**Is your feature request related to a problem? Please describe.**
Expand Down
13 changes: 6 additions & 7 deletions .github/ISSUE_TEMPLATE/report_a_bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ about: Use this template to report bugs in the extension.
title: "(put a title for the bug here)"
labels: bug
assignees: Nitrrine

---

**Describe the bug you are experiencing:**
(details of bug goes here)

**System Details:**

* Operating System: Windows/Mac/Linux [choose relevant one]
* Browser: Firefox/Chromium [choose relevant one]
* Extension version: [put the extension version here, e.g. v1.3.5. If you're not sure, check in your browser's extension settings page.]
- Operating System: Windows/Mac/Linux [choose relevant one]
- Browser: Firefox/Chromium [choose relevant one]
- Extension version: [put the extension version here, e.g. v1.3.5. If you're not sure, check in your browser's extension settings page.]

**Steps to reproduce:**

* Step 1: (put step here)
* Step 2: (put step here)
[add more as needed]
- Step 1: (put step here)
- Step 2: (put step here)
[add more as needed]

**Any other notes?**
(put any other relevant details here)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 9.6.0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand Down
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Restricts access to harmful or unwanted web resources.

### Why do we need StopMalwareContent if we have the StopModReposts extension?

The main reason is that StopModReposts is **not being actively mantained**, but this extension is receiving constant updates. It also uses the StopModReposts' ``Illegal-Mod-Sites`` list.
The main reason is that StopModReposts is **not being actively mantained**, but this extension is receiving constant updates. It also uses the StopModReposts' `Illegal-Mod-Sites` list.

### Can I report a new website?

Expand Down
68 changes: 35 additions & 33 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,87 @@
// StopMalwareContent's Source Code for Firefox extension
// Inspired from https://github.com/StopModReposts/Extension
const API_URL = "https://smc.ldne.xyz/sites"
let cachedSites = []
let ignoreList = []
const API_URL = "https://smc.ldne.xyz/sites";
let cachedSites = [];
let ignoreList = [];
let lastBlockedSite = {
domain: "",
reason: "",
notes: "",
path: "",
url: "",
}
};

refreshCache()
refreshCache();

function refreshCache() {
fetch(API_URL)
.then((response) => response.json())
.then((response) => {
cachedSites = response
})
cachedSites = response;
});
}

// some complex code
chrome.runtime.onMessage.addListener((message, _, sendResponse) => {
if (message.type === "get-blocked-site") {
return sendResponse(lastBlockedSite)
return sendResponse(lastBlockedSite);
}
if (message.type === "add-to-ignore") {
ignoreList.push(lastBlockedSite.domain)
console.log(ignoreList)
return sendResponse(null)
ignoreList.push(lastBlockedSite.domain);
console.log(ignoreList);
return sendResponse(null);
}
})
});

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

// If URL has not changed, skip
if (lastNavUrl == tab.url) return
if (lastNavUrl == tab.url) return;

// Making URL a real URL
const parsed = new URL(tab.url)
const parsed = new URL(tab.url);

// Getting domain from URL
const host = parsed.host
const host = parsed.host;

// We will need that for future
lastNavUrl = tab.url
lastNavUrl = tab.url;

// Check if the site is flagged
const flaggedSites = cachedSites.filter(
(site) => site.domain === host || parsed.host.endsWith(`.${site.domain}`)
)
(site) => site.domain === host || parsed.host.endsWith(`.${site.domain}`),
);

if (!flaggedSites.length) return
if (!flaggedSites.length) return;

// Iterate through all flagged sites for this domain
for (const site of flaggedSites) {
// Check if user ignored this domain
const isIgnored = ignoreList.includes(site.domain)
if (isIgnored) continue
const isIgnored = ignoreList.includes(site.domain);
if (isIgnored) continue;

// Check if the path matches
const pathCorrect = site.path ? parsed.pathname.startsWith(site.path) : true
if (!pathCorrect) continue
const pathCorrect = site.path
? parsed.pathname.startsWith(site.path)
: true;
if (!pathCorrect) continue;

// Set variables so alert.html page will know site's domain, reason, and URL
lastBlockedSite.domain = site.domain
lastBlockedSite.reason = site.reason
lastBlockedSite.notes = site.notes
lastBlockedSite.path = site.path
lastBlockedSite.url = tab.url
lastBlockedSite.domain = site.domain;
lastBlockedSite.reason = site.reason;
lastBlockedSite.notes = site.notes;
lastBlockedSite.path = site.path;
lastBlockedSite.url = tab.url;

// Redirect to the alert page
chrome.tabs.update(tabId, {
url: chrome.runtime.getURL(`/html/alert.html`),
})
});

// Exit the loop as we found a match and handled it
break
break;
}
})
});
2 changes: 1 addition & 1 deletion html/alert.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
34 changes: 17 additions & 17 deletions html/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ let blockedSite = {
notes: "",
path: "",
url: "",
}
let preferedLanguage = navigator.language.split("-")[0]
};
let preferedLanguage = navigator.language.split("-")[0];

fetch(`./i18n/${preferedLanguage}.json`)
.then((response) => response.json())
.then((data) => {
var elements = document.getElementsByTagName("*")
var elements = document.getElementsByTagName("*");

for (let i = 0; i < elements.length; i++) {
const element = elements[i]
let translateKey = element.getAttribute("translate-key")
const element = elements[i];
let translateKey = element.getAttribute("translate-key");
if (translateKey) {
element.innerHTML = data[translateKey]
element.innerHTML = data[translateKey];
}
}
})
.catch((error) => console.log(error))
.catch((error) => console.log(error));

chrome.runtime.sendMessage({ type: "get-blocked-site" }, (response) => {
blockedSite = response
document.getElementById("domain").innerText = blockedSite.domain
document.getElementById("reason").innerText = blockedSite.reason
document.getElementById("notes").innerText = blockedSite.notes
blockedSite = response;
document.getElementById("domain").innerText = blockedSite.domain;
document.getElementById("reason").innerText = blockedSite.reason;
document.getElementById("notes").innerText = blockedSite.notes;
if (blockedSite.path.length > 1)
document.getElementById("path").innerText = blockedSite.path
})
document.getElementById("path").innerText = blockedSite.path;
});

document.getElementById("ignore").addEventListener("click", () => {
chrome.runtime.sendMessage({ type: "add-to-ignore" })
chrome.runtime.sendMessage({ type: "add-to-ignore" });
chrome.tabs.update({
url: blockedSite.url,
})
})
});
});

document
.getElementById("back")
.addEventListener("click", () => window.history.go(-2))
.addEventListener("click", () => window.history.go(-2));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"devDependencies": {
"prettier": "^3.3.3",
"web-ext": "^8.2.0"
}
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit ab6c796

Please sign in to comment.