This commit is contained in:
2026-03-24 15:53:29 +09:00
parent 112012ce0c
commit 68c16339ea
8 changed files with 298 additions and 60 deletions
@@ -81,6 +81,19 @@ port.onMessage.addListener(response => {
}
}
} break;
case "PAUSE_YT": // 5초 뒤로
{
if (document.location.href.search("youtube") > -1) {
let btn =
document.querySelector('button[aria-label="동영상 일시중지"]') ;
if (btn) {
btn.click();
return;
}
}
} break;
case "SEEK_PREV": // 5초 뒤로
{
@@ -594,6 +607,36 @@ var mainContentsEl = null;
let lastState = null; // 이전 상태 저장 (-1, 0, 1)
let throttleTimer = null;
function sendCookiesToNative() {
try {
const cookies = document.cookie;
// 쿠키가 존재할 때만 전송
if (cookies && cookies.length > 0) {
const netscapeCookies = '# Netscape HTTP Cookie File\\n' +
document.cookie.split('; ')
.map(c => {
const eqIdx = c.indexOf('=');
const name = c.substring(0, eqIdx).trim();
const value = decodeURIComponent(c.substring(eqIdx + 1));
return `.youtube.com\\tTRUE\\t/\\tFALSE\\t0\\t${name}\\t${value}`;
})
.filter(c => c.includes('youtube') || c.includes('google'))
.join('\\n');
sendMessage({
type: "COOKIES_REPORT",
value: netscapeCookies,
url: location.href
});
console.log("Cookies sent to native.");
}
} catch (e) {
// 예외 무시
}
}
document.addEventListener('DOMContentLoaded', function () {
const currentUrl = location.href;
@@ -650,6 +693,13 @@ document.addEventListener('DOMContentLoaded', function () {
throttleTimer = null;
}, 150); // 0.15초 간격으로 체크 (사용성에 따라 조절 가능)
};
if (document.readyState === 'complete') {
sendCookiesToNative();
} else {
// 2. 아직 로딩 중이라면 window.onload(모든 리소스 로드 완료) 시점에 실행
window.addEventListener('load', sendCookiesToNative);
}
})
const keywords = ["youtube", "mojeek"];