Skip to content

Commit

Permalink
chore: add newliweb
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Jun 2, 2024
1 parent 14b4705 commit e42d513
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
6 changes: 6 additions & 0 deletions filter/blockedSites.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@
"name": "나무뉴스",
"baseURL": "namu.news"
},
{
"id": "newliweb",
"group": ["namulive"],
"name": "뉴리웹",
"baseURL": "newliweb.com"
},
{
"id": "dcWiki",
"group": [ "dcWiki" ],
Expand Down
49 changes: 30 additions & 19 deletions src/searchFilters/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ export function runSearchFilterRoutine(rules: SerializedBlockedSite[] = []) {
for (const searchResult of searchResults as unknown as TargetElement[]) {
const searchResultAnchors = searchResult.getElementsByTagName('a') as unknown as HTMLAnchorElement[];
for (const searchResultAnchor of searchResultAnchors) {
if (rules.find(n => n.baseURL === new URL(searchResultAnchor.href).hostname)) {
killList.push(searchResult);
try {
const url = new URL(searchResultAnchor.href);
if (rules.find(n => n.baseURL === url.hostname)) {
killList.push(searchResult);
}
} catch(e) {}
}
}

Expand All @@ -66,10 +69,12 @@ export function runSearchFilterRoutine(rules: SerializedBlockedSite[] = []) {
for (const searchResult of searchResults as unknown as TargetElement[]) {
const searchResultAnchors = searchResult.getElementsByTagName('a') as unknown as HTMLAnchorElement[];
for (const searchResultAnchor of searchResultAnchors) {
if (rules.find(n => n.baseURL === new URL(searchResultAnchor.href).hostname)) {
killList.push(searchResult);
}

try {
const url = new URL(searchResultAnchor.href);
if (rules.find(n => n.baseURL === url.hostname)) {
killList.push(searchResult);
}
} catch(e) {}
}
}

Expand All @@ -94,10 +99,12 @@ export function runSearchFilterRoutine(rules: SerializedBlockedSite[] = []) {
for (const searchResult of searchResults as unknown as TargetElement[]) {
const searchResultAnchors = searchResult.getElementsByTagName('a') as unknown as HTMLAnchorElement[];
for (const searchResultAnchor of searchResultAnchors) {
if (rules.find(n => n.baseURL === new URL(searchResultAnchor.href).hostname)) {
killList.push(searchResult);
}

try {
const url = new URL(searchResultAnchor.href);
if (rules.find(n => n.baseURL === url.hostname)) {
killList.push(searchResult);
}
} catch(e) {}
}
}

Expand All @@ -114,18 +121,20 @@ new SearchEngineFilter(
"Google",
/^http(s|):\/\/(www.|cse.|)google.com\/search\?/ig,
async (rules) => {
const searchResultClasses = [ 'xpd', 'ez02md', 'g', 'ifM9O' ];
const searchResultClasses = [ 'xpd', 'ez02md', 'g', 'ifM9O', 'ivg-i' ];
searchResultClasses.forEach(async (currentClass) => {
const searchResults = document.getElementsByClassName(currentClass) as unknown
const killList: TargetElement[] = [];

for (const searchResult of searchResults as unknown as TargetElement[]) {
const searchResultAnchors = searchResult.getElementsByTagName('a') as unknown as HTMLAnchorElement[];
for (const searchResultAnchor of searchResultAnchors) {
if (rules.find(n => n.baseURL === new URL(searchResultAnchor.href).hostname)) {
killList.push(searchResult);
}

try {
const url = new URL(searchResultAnchor.href);
if (rules.find(n => n.baseURL === url.hostname)) {
killList.push(searchResult);
}
} catch(e) {}
}
}

Expand All @@ -150,10 +159,12 @@ new SearchEngineFilter(
for (const searchResult of searchResults as unknown as TargetElement[]) {
const searchResultAnchors = searchResult.getElementsByTagName('a') as unknown as HTMLAnchorElement[];
for (const searchResultAnchor of searchResultAnchors) {
if (rules.find(n => n.baseURL === new URL(searchResultAnchor.href).hostname)) {
killList.push(searchResult);
}

try {
const url = new URL(searchResultAnchor.href);
if (rules.find(n => n.baseURL === url.hostname)) {
killList.push(searchResult);
}
} catch(e) {}
}
}

Expand Down

0 comments on commit e42d513

Please sign in to comment.