This commit is contained in:
2026-11-13 15:08:05 +09:00
parent 6d1dbd46dd
commit a6857505ef
27 changed files with 2119 additions and 667 deletions
@@ -22,7 +22,8 @@
"*://newtoki1.org/novel/*",
"*://*.newtoki1.org/novel/*",
"*://toki35.com/novel/*",
"*://sbxh9.com/novel/*"
"*://sbxh9.com/novel/*",
"*://toki36.com/novel/*"
],
"js": ["inject.js"],
"run_at": "document_start",
@@ -33,7 +34,8 @@
"*://newtoki1.org/novel/*",
"*://*.newtoki1.org/novel/*",
"*://toki35.com/novel/*",
"*://sbxh9.com/novel/*"
"*://sbxh9.com/novel/*",
"*://toki36.com/novel/*"
],
"js": ["content.js"],
"run_at": "document_end"
@@ -1,16 +1,2 @@
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (details.type === "main_frame") {
const currentUrl = details.originUrl || details.documentUrl || "";
// 현재 URL에 'darama'가 포함되어 있는데, 이동할 URL에는 'darama'가 없다면 차단
if (currentUrl.includes("darama") && !details.url.includes("darama")) {
console.log("Redirect blocked for URL:", details.url);
return { cancel: true };
}
}
return {};
},
{ urls: ["<all_urls>"] },
["blocking"] // 요청을 가로채고 취소할 수 있는 권한
);
// Manifest V3에서는 네트워크 차단을 rules.json이 담당하므로 이 파일은 비워둡니다.
console.log("Darama AdBlocker 서비스 워커가 실행되었습니다.");
@@ -0,0 +1,110 @@
// ==UserScript==
// @name Darama Safe Blocker
// @namespace http://tampermonkey.net/
// @version 1.7
// @description 사파리 @allFrames 적용 및 투명 iframe/새 탭 링크 원천 제거
// @match *://*/*
// @run-at document-start
// @inject-into page
// @allFrames true
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 1. 페이지가 그려지기도 전에 CSS로 투명 오버레이 iframe과 외부 새 탭 링크의 터치 판정을 완전히 제거
const style = document.createElement('style');
style.textContent = `
/* 처음에 발견된 전체화면 투명 오버레이 iframe 무력화 */
iframe[style*="2147483647"],
iframe[style*="position: fixed"],
iframe[style*="position:fixed"],
iframe[src="about:blank"],
iframe:not([src]),
/* 외부 도메인으로 새 탭을 여는 투명 링크들의 터치 판정 제거 */
a[target="_blank"]:not([href*="dramadunyam.com"]) {
display: none !important;
pointer-events: none !important;
width: 0 !important;
height: 0 !important;
opacity: 0 !important;
z-index: -999999 !important;
}
`;
(document.head || document.documentElement).appendChild(style);
// 2. window.open 및 동적 a 태그 생성 원천 봉쇄
window.open = function() { return null; };
const origCreateElement = document.createElement;
document.createElement = function(tagName) {
const el = origCreateElement.apply(this, arguments);
if (String(tagName).toLowerCase() === 'a') {
// 광고 스크립트가 메모리 상에서 몰래 <a> 태그를 만들어 클릭시키는 수법 차단
Object.defineProperty(el, 'target', {
get: () => '_self',
set: () => {}
});
}
return el;
};
// 3. 손가락이 화면에 닿는 순간(touchstart, pointerdown) 모든 a 태그의 새 탭 속성 강제 삭제
const neutralizeLink = (e) => {
// Shadow DOM 내부의 링크까지 추적
const path = e.composedPath ? e.composedPath() : [e.target];
for (const node of path) {
if (node && node.tagName === 'A') {
const href = node.href || '';
if (node.target === '_blank' || (href.startsWith('http') && !href.includes('dramadunyam.com'))) {
node.removeAttribute('target');
node.removeAttribute('href');
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
}
}
}
};
['touchstart', 'pointerdown', 'mousedown', 'touchend', 'mouseup', 'click'].forEach(evt => {
window.addEventListener(evt, neutralizeLink, { capture: true, passive: false });
});
// 4. 동적으로 삽입되는 투명 iframe 실시간 제거 (일반 div나 플레이어는 건드리지 않음)
const killAdIframes = () => {
// 모든 외부 _blank 링크 무력화
document.querySelectorAll('a[target="_blank"]').forEach(a => {
if (!a.href || !a.href.includes('dramadunyam.com')) {
a.removeAttribute('target');
a.removeAttribute('href');
a.style.setProperty('pointer-events', 'none', 'important');
}
});
// 투명 덮개 iframe만 정밀 삭제
document.querySelectorAll('iframe').forEach(iframe => {
const s = iframe.getAttribute('style') || '';
const src = iframe.getAttribute('src') || '';
const comp = window.getComputedStyle(iframe);
// 화면에 고정(fixed)되어 있거나 z-index가 비정상적으로 높은 투명 iframe 타격
if (
s.includes('2147483647') ||
s.includes('fixed') ||
comp.position === 'fixed' ||
parseInt(comp.zIndex) > 9999 ||
!src ||
src === 'about:blank'
) {
iframe.remove();
}
});
};
const observer = new MutationObserver(killAdIframes);
observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true });
setInterval(killAdIframes, 150);
})();
@@ -0,0 +1,16 @@
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (details.type === "main_frame") {
const currentUrl = details.originUrl || details.documentUrl || "";
// 현재 URL에 'dramadunyam'이 포함되어 있는데, 이동할 URL에는 'dramadunyam'이 없다면 외부 사이트로 간주하고 차단
if (currentUrl.includes("dramadunyam") && !details.url.includes("dramadunyam")) {
console.log("외부 팝업/리다이렉트 차단됨:", details.url);
return { cancel: true };
}
}
return {};
},
{ urls: ["<all_urls>"] },
["blocking"]
);
@@ -0,0 +1,20 @@
{
"manifest_version": 2,
"version": "1.0",
"name": "Darama AdBlocker (Orion)",
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"run_at": "document_start",
"matches": ["<all_urls>"],
"js": ["messaging.js"]
}
],
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
]
}
@@ -0,0 +1,83 @@
// 1. 투명 링크(a 태그)를 통한 새 탭 열기 완벽 차단
document.addEventListener('click', function(event) {
const aTag = event.target.closest('a');
if (aTag) {
const href = aTag.href || "";
const currentDomain = location.hostname.replace("www.", "");
if (aTag.target === '_blank' && href && !href.includes(currentDomain) && !href.startsWith("/")) {
event.preventDefault();
event.stopPropagation();
console.log("투명 a 태그 외부 광고 클릭 차단됨:", href);
}
}
}, true);
// 2. 자바스크립트(window.open)를 통한 팝업/새 탭 열기 강제 무력화
const script = document.createElement('script');
script.textContent = `
window.open = function() {
console.log("window.open을 통한 새 탭/팝업 열기 차단됨");
return null;
};
`;
(document.head || document.documentElement).appendChild(script);
script.remove();
// 3. 투명 오버레이 덮개 광고 강제 삭제
function removeInvisibleOverlays() {
const elements = document.querySelectorAll('iframe, div, a');
elements.forEach(el => {
const style = window.getComputedStyle(el);
if (
style.zIndex >= 999 &&
(style.position === 'fixed' || style.position === 'absolute') &&
(style.width === '100%' || parseInt(style.width) >= window.innerWidth * 0.9)
) {
console.log("화면 덮개형 광고 요소 강제 삭제됨:", el);
el.remove();
}
});
}
// 4. 공통 광고 요소 및 오버레이 제거 실행 함수
function handleCommon(parentElement) {
if (!parentElement.querySelectorAll) return;
removeInvisibleOverlays();
}
// 5. 페이지 로드 시 초기 정리 작업 실행
document.addEventListener('DOMContentLoaded', function () {
handleCommon(document);
});
// 6. DOM 변화를 감시하여 동적으로 추가되는 아이프레임 광고 차단
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType !== Node.ELEMENT_NODE) return;
// dramadunyam 도메인에서 동적으로 삽입되는 iframe 즉시 삭제
if (location.href.includes("dramadunyam")) {
if (node.tagName === 'IFRAME') {
node.remove();
} else if (node.querySelectorAll) {
node.querySelectorAll('iframe').forEach(iframe => iframe.remove());
}
}
handleCommon(node);
});
});
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
@@ -0,0 +1,35 @@
// 1. 투명 오버레이 덮개 광고 및 불필요한 iframe 제거
function cleanUpAds() {
// 화면 전체를 덮는 투명 막(div, a, iframe) 제거
const elements = document.querySelectorAll('iframe, div, a');
elements.forEach(el => {
const style = window.getComputedStyle(el);
if (
parseInt(style.zIndex) >= 999 &&
(style.position === 'fixed' || style.position === 'absolute') &&
(style.width === '100%' || parseInt(style.width) >= window.innerWidth * 0.9)
) {
el.remove();
}
});
// 동적으로 삽입되는 광고용 iframe 제거
document.querySelectorAll('iframe').forEach(iframe => {
const src = iframe.getAttribute('src') || '';
// 본문 영상 플레이어가 아닌 빈 iframe이나 광고성 iframe 삭제
if (!src || src === 'about:blank' || parseInt(window.getComputedStyle(iframe).zIndex) > 100) {
iframe.remove();
}
});
}
// 초기 실행
cleanUpAds();
// 2. 화면 조작(클릭 등) 시 동적으로 추가되는 광고 실시간 감시 및 삭제
if (document.body) {
const observer = new MutationObserver(() => {
cleanUpAds();
});
observer.observe(document.body, { childList: true, subtree: true });
}
@@ -0,0 +1,17 @@
// 1. 자바스크립트 window.open 무력화
window.open = function() {
return null;
};
// 2. 외부로 이동하는 새 탭(_blank) 링크 클릭 가로채기
window.addEventListener('click', function(event) {
const aTag = event.target.closest ? event.target.closest('a') : null;
if (aTag) {
const href = aTag.href || "";
const currentDomain = location.hostname.replace("www.", "");
if (aTag.target === '_blank' && href && !href.includes(currentDomain) && !href.startsWith("/")) {
event.preventDefault();
event.stopPropagation();
}
}
}, true);
@@ -0,0 +1,33 @@
{
"manifest_version": 3,
"name": "Darama support",
"version": "1.2",
"description": "dramadunyam.com 전용 투명 아이프레임 및 새 탭 광고 차단기",
"action": {
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"scripting",
"storage"
],
"content_scripts": [
{
"matches": [
"*://dramadunyam.com/*",
"*://*.dramadunyam.com/*"
],
"js": ["inject.js"],
"run_at": "document_start",
"world": "MAIN"
},
{
"matches": [
"*://dramadunyam.com/*",
"*://*.dramadunyam.com/*"
],
"js": ["content.js"],
"run_at": "document_end"
}
]
}
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<style>
body { width: 200px; padding: 12px; font-family: sans-serif; text-align: center; background: #f9f9f9; }
.status { color: #27ae60; font-weight: bold; font-size: 14px; margin-bottom: 5px; }
.desc { font-size: 12px; color: #666; margin: 0; }
</style>
</head>
<body>
<div class="status">✓ Darama 차단기 작동 중</div>
<p class="desc">dramadunyam.com의 새 탭 및 오버레이 광고를 방어합니다.</p>
</body>
</html>
@@ -1,9 +1,9 @@
{
"manifest_version": 2,
"manifest_version": 3,
"version": "1.0",
"name": "Darama AdBlocker",
"background": {
"scripts": ["background.js"]
"service_worker": "background.js"
},
"content_scripts": [
{
@@ -13,9 +13,18 @@
}
],
"permissions": [
"cookies",
"<all_urls>",
"webRequest",
"webRequestBlocking"
]
"declarativeNetRequest"
],
"host_permissions": [
"<all_urls>"
],
"declarative_net_request": {
"rule_resources": [
{
"id": "block_redirects",
"enabled": true,
"path": "rules.json"
}
]
}
}
@@ -1,17 +1,70 @@
// 1. 페이지 로드 시 정적 광고 및 불필요한 요소 즉시 제거
// 1. 투명 링크(a 태그)를 통한 새 탭 열기 완벽 차단
document.addEventListener('click', function(event) {
const aTag = event.target.closest('a');
if (aTag) {
const href = aTag.href || "";
const currentDomain = location.hostname.replace("www.", "");
if (aTag.target === '_blank' && href && !href.includes(currentDomain) && !href.startsWith("/")) {
event.preventDefault();
event.stopPropagation();
console.log("투명 a 태그 외부 광고 클릭 차단됨:", href);
}
}
}, true);
// 2. 자바스크립트(window.open)를 통한 팝업/새 탭 열기 강제 무력화
const script = document.createElement('script');
script.textContent = `
window.open = function() {
console.log("window.open을 통한 새 탭/팝업 열기 차단됨");
return null;
};
`;
(document.head || document.documentElement).appendChild(script);
script.remove();
// 3. 투명 오버레이 덮개 광고 강제 삭제
function removeInvisibleOverlays() {
const elements = document.querySelectorAll('iframe, div, a');
elements.forEach(el => {
const style = window.getComputedStyle(el);
if (
style.zIndex >= 999 &&
(style.position === 'fixed' || style.position === 'absolute') &&
(style.width === '100%' || parseInt(style.width) >= window.innerWidth * 0.9)
) {
console.log("화면 덮개형 광고 요소 강제 삭제됨:", el);
el.remove();
}
});
}
// 4. 공통 광고 요소 및 오버레이 제거 실행 함수
function handleCommon(parentElement) {
if (!parentElement.querySelectorAll) return;
removeInvisibleOverlays();
}
// 5. 페이지 로드 시 초기 정리 작업 실행
document.addEventListener('DOMContentLoaded', function () {
handleCommon(document);
// applyDomainRules();
});
// 2. DOM 변화를 실시간 감시하여 동적 아이프레임 및 광고 추가 완벽 차단
// 6. DOM 변화를 감시하여 동적으로 추가되는 아이프레임 광고 차단
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType !== Node.ELEMENT_NODE) return;
// [darama 도메인] 동적으로 삽입되는 iframe 즉시 삭제
if (location.href.includes("darama")) {
// dramadunyam 도메인에서 동적으로 삽입되는 iframe 즉시 삭제
if (location.href.includes("dramadunyam")) {
if (node.tagName === 'IFRAME') {
node.remove();
} else if (node.querySelectorAll) {
@@ -19,7 +72,6 @@ const observer = new MutationObserver((mutations) => {
}
}
// 동적으로 삽입되는 공통 광고 노드 지속 삭제
handleCommon(node);
});
});
@@ -28,51 +80,4 @@ const observer = new MutationObserver((mutations) => {
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
// 3. 공통 광고 요소 제거 함수 (정적/동적 DOM 모두 대응)
function handleCommon(parentElement) {
if (!parentElement.querySelectorAll) return;
// const adSelectors = [
// ".top_google_ad_space", ".adv-group", "[id^='div-gpt-ad']",
// "[id^='div_adnmore_area']", "[class^='adv-groupno']", ".code-block",
// ".ad-template", "#xpromo-bottom-sheet", "[data-banner^='coupang-']",
// "[id^='mobonDivBanner']", "[id^='pnlTopAd']", "[class^='ad-tag']",
// "[class^='science-banner-area']"
// ];
//
// adSelectors.forEach(selector => {
// parentElement.querySelectorAll(selector).forEach(e => e.remove());
// });
// parentElement.querySelectorAll('iframe').forEach(e => {
// const src = e.getAttribute("src");
// if (src && (src.includes("ads") || src.includes("coupang"))) {
// e.remove();
// }
// });
}
// 4. 도메인별 맞춤형 요소 제거 (기존 룰 단순화)
function applyDomainRules() {
const url = location.href;
if (url.includes("nate.com")) {
document.querySelectorAll('[class^="float-adv-wrap"], [id^="ad_"], #ad_sponsorBar, #newsSidebar, iframe[id^="ad"]').forEach(e => e.remove());
} else if (url.includes("zdnet.co.kr")) {
document.querySelectorAll('div[id*="FloatCon"]').forEach(e => e.remove());
} else if (url.includes("inews24")) {
document.querySelectorAll('ad[alt^="a"], div[class^="topnews"], form[class^="talkplus"], ins, footer').forEach(e => e.remove());
} else if (url.includes("starnewskorea")) {
document.querySelectorAll('div[class^="floating-top-ad"], div[id^="dablewidget_"], footer').forEach(e => e.remove());
} else if (url.includes("khan.co.kr")) {
document.querySelectorAll('[class^="banner-"], [class^="google-auto-placed"], footer, iframe').forEach(e => e.remove());
} else if (url.includes("dcinside.com")) {
document.querySelectorAll('[id^="view_btn_area"], [class^="trend-rank"], [class^="adv-group"], [id^="div_adnmore_area"]').forEach(e => e.remove());
} else if (url.includes("fmkorea.com")) {
document.querySelectorAll('[class^="fmad_wrapper"], [class^="ad ad_wrapper"], [class^="m_top_hotdeal"]').forEach(e => e.remove());
} else if (url.includes("theqoo.net")) {
document.querySelectorAll('[class^="board_content_google_ad"], ins[class^="adsbygoogle"]').forEach(e => e.remove());
}
}
});
@@ -0,0 +1,15 @@
[
{
"id": 1,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"urlFilter": "*",
"excludedUrlFilter": "*dramadunyam*",
"initiatorDomains": ["dramadunyam.com"],
"resourceTypes": ["main_frame"]
}
}
]
File diff suppressed because it is too large Load Diff