Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 351e3a2

Browse files
Add and updat ethe projec with description
1 parent 8bf1afc commit 351e3a2

File tree

4 files changed

+63
-52
lines changed

4 files changed

+63
-52
lines changed

‎README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,17 @@ In order to run this project you need:
584584
</details>
585585
</li>
586586

587+
<li>
588+
<details>
589+
<summary>Ads Blocker Extension</summary>
590+
<p>This is a simple Ad Blocker Extension. AdBlocker is a lightweight browser extension designed to block intrusive advertisements and enhance your browsing experience.</p>
591+
<ul>
592+
<li><a href="https://tajulafreen.github.io/50Projects-HTML-CSS-JavaScript/Source-Code/AdsBlockerExtension/">Live Demo</a></li>
593+
<li><a href="https://github.com/tajulafreen/50Projects-HTML-CSS-JavaScript/tree/main/Source-Code/AdsBlockerExtension">Source</a></li>
594+
</ul>
595+
</details>
596+
</li>
597+
587598
</ol>
588599

589600
<p align="right">(<a href="#readme-top">back to top</a>)</p>

‎Source-Code/AdsBlockerExtension/content.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
/* eslint-disable no-undef */
12
const adSelectors = [
23
'iframe[src*="ads"]',
34
'div[class*="ad"]',
45
'div[id*="ad"]',
5-
"ins.adsbygoogle",
6-
"[data-ad]",
7-
".ad-banner",
6+
'ins.adsbygoogle',
7+
'[data-ad]',
8+
'.ad-banner',
89
];
910

1011
// Normalize domain
11-
const normalizeDomain = (domain) => domain.replace(/^www\./, "");
12+
const normalizeDomain = (domain) => domain.replace(/^www\./, '');
1213

1314
chrome.storage.local.get(
1415
{ adBlockerEnabled: true, whitelist: [] },
@@ -37,5 +38,5 @@ chrome.storage.local.get(
3738
// Observe dynamically loaded ads
3839
const observer = new MutationObserver(blockAds);
3940
observer.observe(document.body, { childList: true, subtree: true });
40-
}
41+
},
4142
);
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
body {
2-
font-family: Arial, sans-serif;
3-
margin: 10px;
4-
width: 250px;
5-
}
6-
7-
h1 {
8-
font-size: 1.5em;
9-
margin-bottom: 10px;
10-
}
11-
12-
label {
13-
display: block;
14-
margin-bottom: 20px;
15-
}
16-
17-
input {
18-
margin-right: 10px;
19-
}
20-
21-
ul {
22-
list-style-type: none;
23-
padding: 0;
24-
}
25-
26-
li {
27-
margin: 5px 0;
28-
display: flex;
29-
justify-content: space-between;
30-
}
31-
32-
button {
33-
cursor: pointer;
34-
}
35-
2+
font-family: Arial, sans-serif;
3+
margin: 10px;
4+
width: 250px;
5+
}
6+
7+
h1 {
8+
font-size: 1.5em;
9+
margin-bottom: 10px;
10+
}
11+
12+
label {
13+
display: block;
14+
margin-bottom: 20px;
15+
}
16+
17+
input {
18+
margin-right: 10px;
19+
}
20+
21+
ul {
22+
list-style-type: none;
23+
padding: 0;
24+
}
25+
26+
li {
27+
margin: 5px 0;
28+
display: flex;
29+
justify-content: space-between;
30+
}
31+
32+
button {
33+
cursor: pointer;
34+
}

‎Source-Code/AdsBlockerExtension/popup.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
const whitelistInput = document.getElementById("whitelist-input");
2-
const addToWhitelist = document.getElementById("add-to-whitelist");
3-
const whitelist = document.getElementById("whitelist");
4-
let whitelistData = JSON.parse(localStorage.getItem("whitelist")) || [];
1+
const whitelistInput = document.getElementById('whitelist-input');
2+
const addToWhitelist = document.getElementById('add-to-whitelist');
3+
const whitelist = document.getElementById('whitelist');
4+
let whitelistData = JSON.parse(localStorage.getItem('whitelist')) || [];
55

66
// Load whitelist
77
function loadWhitelist() {
8-
whitelist.innerHTML = "";
8+
whitelist.innerHTML = '';
99
whitelistData.forEach((site) => {
10-
const li = document.createElement("li");
10+
const li = document.createElement('li');
1111
li.textContent = site;
12-
const removeBtn = document.createElement("button");
13-
removeBtn.textContent = "Remove";
14-
removeBtn.addEventListener("click", () => {
12+
const removeBtn = document.createElement('button');
13+
removeBtn.textContent = 'Remove';
14+
removeBtn.addEventListener('click', () => {
1515
whitelistData = whitelistData.filter((item) => item !== site);
16-
localStorage.setItem("whitelist", JSON.stringify(whitelistData));
16+
localStorage.setItem('whitelist', JSON.stringify(whitelistData));
1717
loadWhitelist();
1818
});
1919
li.appendChild(removeBtn);
2020
whitelist.appendChild(li);
2121
});
2222
}
2323

24-
addToWhitelist.addEventListener("click", () => {
24+
addToWhitelist.addEventListener('click', () => {
2525
const site = whitelistInput.value.trim();
2626
if (site && !whitelistData.includes(site)) {
2727
whitelistData.push(site);
28-
localStorage.setItem("whitelist", JSON.stringify(whitelistData));
29-
whitelistInput.value = "";
28+
localStorage.setItem('whitelist', JSON.stringify(whitelistData));
29+
whitelistInput.value = '';
3030
loadWhitelist();
3131
}
3232
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /