Auto somi

자동 복호화/국룰입력/다운(Kiosk, Mega, GoogleDrive, goFile)

目前為 2025-05-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Auto somi
// @name:ko      자동 소미
// @namespace    http://tampermonkey.net/
// @description  자동 복호화/국룰입력/다운(Kiosk, Mega, GoogleDrive, goFile)
// @version      new 3.0
// @author       김머시기
// @match        https://kiosk.ac/c/*
// @match        https://kio.ac/c/*
// @match        https://kone.gg/*
// @match        https://arca.live/b/*
// @match        https://mega.nz/*
// @match        https://gofile.io/d/*
// @match        https://workupload.com/*
// @match        https://drive.google.com/file/d/*
// @match        https://drive.google.com/drive/folders/*
// @match        https://drive.usercontent.google.com/download?id*
// @icon         https://lh3.google.com/u/0/d/18OVO7VmnwIuHK6Ke-z7035wKFmMKZ28W=w1854-h959-iv1
// @grant        GM.setValue
// @grant        GM.getValue
// @require      https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant        GM.registerMenuCommand
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @license      MIT
// @run-at       document-end
// ==/UserScript==
'use strict';
let chkp = [,,,, atob('c29taXNvZnQ=')], Down_Option, PageLoading = [], isT = [,,], MenuID = [null, null], host = document.URL.split('/')[2], npw = [], pw = [atob('c29taXNvZnQ='),atob('MjAyNXNvbWlzb2Z0'),
// =============================== Settings =======================================
// 추가하길 원하는 비밀번호 따옴표 - 쉼표로 구분해서 바로 아래줄에 넣으면 됨 ex) '1234', '2024국룰', '!국룰!'

];
PageLoading[0] = 1000;     // 페이지 로딩 시간 조절 (1000당 1초)
Down_Option = 0;           // Kiosk 다운로드 옵션 0:Basic, 1:Fast, 2:일괄 다운로드
// ======================================================================================

function getKoneGGContentElement() {
    if (host !== 'kone.gg') return null;
    const proseContainer = document.querySelector('div.prose-container');
    if (!proseContainer || !proseContainer.shadowRoot) return null;
    const contentDiv = proseContainer.shadowRoot.querySelector('div.content');
    return contentDiv;
}



function handleBlockingModals(currentHost) {
    if (currentHost === 'kone.gg') {
        const nsfwOverlayContainer = document.querySelector('div.relative.min-h-60 > div.absolute.w-full.h-full.backdrop-blur-2xl');
        if (nsfwOverlayContainer && nsfwOverlayContainer.offsetParent !== null) {
            const viewContentButton = nsfwOverlayContainer.querySelector('div.flex.gap-4 button:nth-child(2)');
            if (viewContentButton && viewContentButton.textContent?.includes('콘텐츠 보기')) {
                viewContentButton.click();
                return new Promise(resolve => setTimeout(resolve, 500));
            } else {
                const modalSelectorsKone = [
                    '.age-verification-popup',
                    '.content-overlay.block',
                ];
                modalSelectorsKone.forEach(selector => hideElement(selector));
            }
        }
    } else if (currentHost === 'arca.live') {
        const modalSelectorsArca = [
            { selector: '.adult-confirm-modal', action: 'hide' },
            { selector: '.fc-dialog', action: 'hide' },
            { selector: '#preview-block-layer', action: 'hide' },
            { selector: 'div[class*="adult-channel-confirm"]', action: 'hide' },
            { selector: 'div.modal[data-id="confirmAdult"] div.modal-footer button.btn-primary', action: 'click'},
            { selector: 'button.btn-primary.btn.text-light[data-bs-dismiss="modal"]', action: 'click' }
        ];
        modalSelectorsArca.forEach(item => {
            const elements = document.querySelectorAll(item.selector);
            elements.forEach(element => {
                if (element && element.offsetParent !== null) {
                    if (item.action === 'click') {
                        element.click();
                    } else {
                        hideElement(item.selector);
                    }
                }
            });
        });
    }

    function hideElement(selector) {
        try {
            const elements = document.querySelectorAll(selector);
            if (elements.length > 0) {
                elements.forEach(el => {
                    if (el.offsetParent !== null) {
                        el.style.setProperty('display', 'none', 'important');
                    }
                });
            }
        } catch (e) {
            console.error(e);
        }
    }
    return Promise.resolve();
}


async function toggleDown(){
	isT[0]=!isT[0];
	if(!isT[0] && isT[1]){
		isT[1]=false;
		await GM.setValue('isT[1]', isT[1]);
	}
	await GM.setValue('isT[0]', isT[0]);
	updateDown();
	updateTab();
}
async function toggleTab(){
	isT[1]=!isT[1];
	if(!isT[0] && isT[1]){
		isT[0]=true;
		await GM.setValue('isT[0]', isT[0]);
	}
	await GM.setValue('isT[1]', isT[1]);
	updateDown();
	updateTab();
}
function updateDown(){
	if(MenuID[0] !==null)GM_unregisterMenuCommand(MenuID[0]);
	MenuID[0]=GM_registerMenuCommand(`자동 다운로드  ${isT[0] ? 'ON' : 'OFF'}`, toggleDown, { autoClose: false, title: `자동 다운로드 ${isT[0] ? '켜짐' : '꺼짐'}`});
}
function updateTab(){
	if(MenuID[1] !==null)GM_unregisterMenuCommand(MenuID[1]);
	MenuID[1]=GM_registerMenuCommand(`자동 탭 닫기   ${isT[1] ? 'ON' : 'OFF'}`, toggleTab, { autoClose: false, title: `자동 탭 닫기 ${isT[1] ? '켜짐' : '꺼짐'}`});
}
function doDec() {
    if (chkp[3] !== chkp[4]) return;

    let targets = [];

    if (host === 'arca.live') {
        targets = [
            document.querySelector('body div.article-body > div.fr-view.article-content'),
            ...document.querySelectorAll('div.article-comment#comment div.comment-content, div.article-comment div.comment-content')
        ].filter(el => el !== null);
    } else if (host === 'kone.gg') {
        const koneContentElement = getKoneGGContentElement();
        const comments = document.querySelectorAll('p.text-sm.max-w-xl.whitespace-pre-wrap');
        const listItems = document.querySelectorAll('ol.list-decimal li p');
        targets = [koneContentElement, ...comments, ...listItems].filter(el => el !== null);
    }

    if (targets.length === 0 || (targets.length === 1 && !targets[0])) return;

    function dec(target, reg) {
        try {
            if (!target || !target.innerHTML) return;
            const original = target.innerHTML;
            const matches = [...original.matchAll(reg)];
            if (matches.length === 0) return;

            let result = original;
            let decodedCount = 0;
            for (const match of matches) {
                let encoded = match[0];
                let decoded = encoded;
                try {
                    while (decoded && typeof decoded === 'string' && !decoded.startsWith('http') && decoded.length > 10 && decoded.length < 1000) {
                        let tempDecoded = atob(decoded);
                        if (tempDecoded === decoded) break;
                        decoded = tempDecoded;
                    }
                    if (decoded && typeof decoded === 'string' && decoded.startsWith('http')) {
                        const linkHTML = `<a href="${decoded}" target="_blank" rel="noreferrer" style="color:#007bff; text-decoration:underline; word-break:break-all;">${decoded}</a>`;
                        result = result.replace(encoded, linkHTML);
                            decodedCount++;
                    }
                } catch (e) {
                }
            }
            if (target.innerHTML !== result) {
                target.innerHTML = result;
            }
        } catch (e) {
            console.error(e, target);
        }
    }

    for (const target of targets) {
        if (!target) continue;
        const links = target.querySelectorAll('a');
        links.forEach(a => {
            a.setAttribute('rel', 'noreferrer');
        });

        dec(target, /aHR0c[0-9A-Za-z+/=]{8,}/g);
        dec(target, /YUhSMG[0-9A-Za-z+/=]{8,}/g);
        dec(target, /WVVoU[0-9A-Za-z+/=]{8,}/g);
        dec(target, /V1ZWb[0-9A-Za-z+/=]{8,}/g);
    }
    setTimeout(doDlsiteContextAware, 100);
}


function doDlsiteContextAware() {
    let atc;
    if (host === 'arca.live') {
        atc = document.querySelector('.article-body .article-content');
    } else if (host === 'kone.gg') {
        atc = getKoneGGContentElement();
    }

    if (!atc) return;

    const existingAppendedLink = atc.querySelector('.dlsite-link-appended');
    if (existingAppendedLink) {
        existingAppendedLink.remove();
    }

    let titleEl;
    if (host === 'arca.live') {
        titleEl = document.querySelector('.title-row .title') || document.querySelector('.board-title .title');
    } else if (host === 'kone.gg') {
        titleEl = [...document.querySelectorAll('h1')].find(el =>
            el.textContent?.match(/RJ[0-9]{6,10}/i)
        );
    }

    const keywordPattern = /(꺼|거|퍼|RJ|rj|Rj|rJ|VJ|vj|Vj|vJ|DL|dl|Dl|dL)[\s:()\[\]#-]*([0-9]{6,10})/g;
    const fullRJPattern = /\b(RJ|rj|Rj|rJ|VJ|vj|Vj|vJ|퍼|꺼|거|DL|dl|Dl|dL)([0-9]{6,10})\b/g;

    let titleText = '';
    if (titleEl?.childNodes) {
        titleText = Array.from(titleEl.childNodes)
            .map(n => n.textContent?.trim() || '')
            .join(' ');
    }

    const bodyText = atc.textContent || '';
    const fullText = titleText + '\n' + bodyText;

    const allFoundCodes = new Map();
    let match;

    const combinedRegex = new RegExp(`${keywordPattern.source}|${fullRJPattern.source}`, 'gi');
    while ((match = combinedRegex.exec(fullText)) !== null) {
        const prefix = (match[1] || match[3] || '').toLowerCase();
        const code = match[2] || match[4];
        if (code && !allFoundCodes.has(code)) {
            allFoundCodes.set(code, { prefix: prefix, originalText: match[0] });
        }
    }

    const uniqueCodes = Array.from(allFoundCodes.keys());

    if (uniqueCodes.length <= 1) {
        if (uniqueCodes.length === 1) {
            const code = uniqueCodes[0];
            const { prefix } = allFoundCodes.get(code);

            const mappedPrefix = ['vj', 'vJ', 'Vj', 'VJ', '퍼'].includes(prefix) ? 'VJ'
                                : ['rj', 'rJ', 'Rj', 'RJ', '꺼', '거', 'dl', 'dL', 'Dl', 'DL'].includes(prefix) ? 'RJ'
                                : prefix.toUpperCase();

            const fullCode = `${mappedPrefix}${code}`;
            const link = `https://www.dlsite.com/maniax/work/=/product_id/${fullCode}.html`;

            const wrapper = document.createElement('div');
            wrapper.className = 'dlsite-link-appended';
            wrapper.style.marginTop = '15px';
            wrapper.style.padding = '10px 0';
            wrapper.style.borderTop = '1px dashed #aaa';

            const a = document.createElement('a');
            a.href = link;
            a.target = '_blank';
            a.rel = 'noreferrer';
            a.textContent = `[DLsite] ${fullCode}`;
            a.style.display = 'block';
            a.style.marginBottom = '5px';
            a.style.color = '#1e90ff';

            wrapper.appendChild(a);
            atc.appendChild(wrapper);
        }
        return;
    }

    let tempDiv = document.createElement('div');
    tempDiv.innerHTML = atc.innerHTML;

    allFoundCodes.forEach(({ prefix, originalText }, code) => {
        const mappedPrefix = ['vj', 'vJ', 'Vj', 'VJ', '퍼'].includes(prefix) ? 'VJ'
                            : ['rj', 'rJ', 'Rj', 'RJ', '꺼', '거', 'dl', 'dL', 'Dl', 'DL'].includes(prefix) ? 'RJ'
                            : prefix.toUpperCase();
        const fullCode = `${mappedPrefix}${code}`;
        const link = `https://www.dlsite.com/maniax/work/=/product_id/${fullCode}.html`;

        const escapedOriginalText = originalText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
        const replaceRegex = new RegExp(`(${escapedOriginalText})(?![^<]*>|[^<>]*<\/a>)`, 'g');

        tempDiv.innerHTML = tempDiv.innerHTML.replace(replaceRegex, `<a href="${link}" target="_blank" rel="noreferrer" style="color:#1e90ff;">$1</a>`);
    });

    atc.innerHTML = tempDiv.innerHTML;
}


async function chkPW(){
	chkp[3]=await GM.getValue('chkp[3]');
	isT[0]=await GM.getValue('isT[0]', true);
	isT[1]=await GM.getValue('isT[1]', false);
	updateDown();
	updateTab();

	if(host=='arca.live' || host=='kone.gg'){
		if(chkp[3] !=chkp[4]){
			const chk=prompt(atob('7JWI65Oc7JW47JqU67mE67mMIOuwnOq5gOyImCDqtoHrnoTrnbzrsLg='));
			if(chk?.toLowerCase()==chkp[4]) {
                await GM.setValue('chkp[3]', chkp[4]);
            } else {
				GM.setValue('chkp[3]', false);
				alert(atob('7JWI65Oc7JW47JqU67mE67mMIOuwnOq5gOyImCDqtoHrnoQgfOyImCDstqAg67mE64uk66yMIOuwnOq5gOyImCBp7JiB66GcIOuwnOq5gOyImCDslpHsmIjqsIDqtoQgfOydjCDruYTruYDqsIDqtoQg66yM66asIOyImCDsmIHqsIDrsJwg7JWI65Oc7JW47JqU7KeA7Juw67mI64uI'));
			}
		} else {
        }
	}
}
async function inputPW() {
    let inputElem = document.querySelector(chkp[0]), btnElem = document.querySelector(chkp[1]);
    if (!inputElem ) {
        if (isT[0] === true && !document.querySelector('.files-list, #download-section')) {
             await setTimeout(DBtn, PageLoading[1] || 1000);
        }
        return;
    }

    const combinedPw = [...new Set([...pw, ...npw])];

    if (chkp[3] == chkp[4]) {
        try {
            for (let i = 0; i < combinedPw.length; i++) {
                if (!combinedPw[i]) continue;
                if (!inputElem) break;

                inputElem.value = combinedPw[i];

                if (host == 'kio.ac') {
                    inputElem.dispatchEvent(new Event('input', { bubbles: true }));
                    inputElem.dispatchEvent(new Event('change', { bubbles: true }));
                    await new Promise(res => setTimeout(res, 50));
                    if(btnElem) btnElem.click();
                } else {
                    if(btnElem) btnElem.click();
                    else {
                        const enterEvent = new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true });
                        inputElem.dispatchEvent(enterEvent);
                    }
                }

                await new Promise(res => setTimeout(res, 800));

                const successIndicator = document.querySelector('.files-list, #download-section, .download-link, .btn-download, .main-button-download');
                const errorIndicator = document.querySelector('.text-error, .text-red-500, .error-message, .incorrect-password, [class*="error"], [id*="error"]');

                if (successIndicator && successIndicator.offsetParent !== null) {
                    break;
                } else if (errorIndicator && errorIndicator.offsetParent !== null) {
                    if (inputElem) inputElem.value = '';
                } else {
                }
            }
            if (isT[0] == true) {
                await setTimeout(DBtn, PageLoading[1] || 1000);
            }

        } catch (e) {
            console.error(e);
            if (isT[0] == true) {
                await setTimeout(DBtn, PageLoading[1] || 1000);
            }
        }
    } else {
    }
}

async function kioskdone(){
	try {
		await new Promise(res=> setTimeout(res, 3000));
		for(var i=0, jj=0; jj!=1; i++){
			console.log(i);
			await new Promise(res=> setTimeout(res, 1000));
			if(document.querySelector('.flex.flex-row.text-xs.justify-between div:nth-child(2)').innerText=='done'){
				console.log(i);
				await setTimeout(()=> { window.open('', '_self').close()}, 2000);
				jj++;
			}
		}
	} catch(e){ if(isT[1]==true && isT[2]==true)setTimeout(()=> { window.open('', '_self').close()}, 1000); }
}
async function DBtn(){
	if(isT[0] !== true) {
        return;
    }

	if(host=='mega.nz') {
        try {
            const resumeButton = document.querySelector('.mega-button.positive.resume.js-resume-download');
            if (resumeButton) {
                resumeButton.click();
                await new Promise(res => setTimeout(res, 500));
            }

            const standardDownloadButton = document.querySelector('.mega-button.positive.js-default-download.js-standard-download');
            if (standardDownloadButton) {
                standardDownloadButton.click();
                await new Promise(res => setTimeout(res, 2000));
            }

            const continueDownloadButton = document.querySelector('.mega-button.large.positive.download.continue-download');
            if (continueDownloadButton) {
                continueDownloadButton.click();
            }
        } catch(e) {
            console.error(e);
        }
    } else {
        try {
            let btns = document.querySelectorAll(chkp[2]);
            let delayMultiplier = (PageLoading[0] || 1000) + 600;
            if(btns.length > 1){
                btns.forEach((btn, index) => {
                    setTimeout(() => {
                        btn.click();
                    }, index * delayMultiplier);
                });
            } else if(btns.length === 1){
                btns[0].click();
            } else {
            }
        } catch(e){ console.error(e); }
    }

	if(isT[1]==true && isT[2]==true){
        let btnsForDelay = document.querySelectorAll(chkp[2]);
		let totalDelay = (btnsForDelay.length > 1) ? (btnsForDelay.length * ((PageLoading[0] || 1000) + 600) + 700) : 1300;
		if(host=='kiosk.ac'){
			setTimeout(()=> { kioskdone(); }, totalDelay);
		} else if(host=='kio.ac'){
			setTimeout(()=> { window.open('', '_self').close()}, totalDelay+1000);
		} else {
			setTimeout(()=> { window.open('', '_self').close()}, totalDelay);
		}
	}
}

function FindPW(){
    let atc;
    if (host === 'arca.live') {
        atc = document.querySelector('body div.article-body > div.fr-view.article-content');
    } else if (host === 'kone.gg') {
        atc = getKoneGGContentElement();
    }

    if (!atc || !atc.innerHTML) return;

    let tempContent = atc.innerHTML;
    tempContent=tempContent.replace(/ /g, ' ').replace(/( ){2,}/g, ' ');
	tempContent=tempContent.replace(/국룰/g, 'ㄱㄹ');

	let regexx=/(대문자)/;

	if(regexx.test(tempContent)) {
        const smpeopleUpper = atob('U01QRU9QTEU=');
        if (npw.indexOf(smpeopleUpper) === -1) {
            npw.push(smpeopleUpper);
        }
    }

	function dec(reg){
        let foundPasswordsInDec = 0;
		try {
            let currentLoopContent = tempContent;
            const processedTexts = new Set();

			while(true){
                const matchResult = reg.exec(currentLoopContent);
                if (!matchResult) break;

				let matchedText = matchResult[0];
                if (processedTexts.has(matchedText)) {
                    currentLoopContent = currentLoopContent.replace(matchedText, `__SKIPPED_${Math.random().toString(36).substring(2, 10)}__`);
                    continue;
                }

                let DECed = matchedText.replace(/(ㄱㄹ)/g, '국룰');
				let DECedd = DECed.replace(/\s|[+]|(은|는|이|가)|(전부)|(대문자로)|(대문자)|(비밀번호)|(패스워드)|(비번)|(ㅂㅂ)|(암호)|(ㅇㅎ)|(키오스크맘)|(키오스크)|(입니다)|(이고)|(이며)|(임다)|(같다)|(처럼)|(틀리다)|(입니다요)/g, '');
				DECedd = DECedd.split(/[(입)(임)(이)(이)(이)(입)(임)(같)(처)(틀)]/g)[0];
                DECedd = DECedd.replace(/[<>]/g, '');

				let dat;
                if (host === 'arca.live') {
                    const dateEl = document.querySelector('.article-info .date .body');
                    if (dateEl && typeof dateEl.innerText === 'string' && dateEl.innerText.trim() !== '') {
                        dat = dateEl.innerText.split(' ')[0];
                    } else {
                        dat = undefined;
                    }
                }

				let regexa=/(오늘)|(날짜)|(날자)/g;
				if(dat && regexa.test(DECedd)){
					DECedd=DECedd.replace(regexa, '');
                    const dateParts = dat.split(/\-/g);
                    if (dateParts.length === 3) {
                        const year = dateParts[0].slice(2);
                        const month = dateParts[1];
                        const day = dateParts[2];
                        let dateFormats=[month + day, month + '-' + day, year + month + day, dat.replace(/-/g,'')];
                        for(let k=0;k<dateFormats.length;k++){
                            const finalPw = DECedd.replace(/국룰/g,chkp[4]) + dateFormats[k];
                            if(finalPw.length > 2 && npw.indexOf(finalPw)=='-1') {
                                npw.push(finalPw);
                            }
                        }
                    }
				} else {
                    const finalPw = DECedd.replace(/국룰/g,chkp[4]);
                    if(finalPw && finalPw.length > 2 && npw.indexOf(finalPw)=='-1') {
                        npw.push(finalPw);
                        foundPasswordsInDec++;
                    }
                }
                processedTexts.add(matchedText);
                currentLoopContent = currentLoopContent.replace(matchedText, `__PROCESSED_${Math.random().toString(36).substring(2, 15)}__`);
			}
            if (foundPasswordsInDec > 0) {}
			GM.setValue('npw', npw);
		} catch(e){ console.error(e); }
	}
	dec(/[(<p>\s*)*]{0,}[ㄱ-ㅣ가-힣0-9A-Za-z\s~`!^\_+@\#$%&=]{0,}(ㄱㄹ){1,1}[ㄱ-ㅣ가-힣0-9A-Za-z\s~`!^\_+@\#$%&=]{0,}[(\s*</p>)*]{0,}/);
	setTimeout(aaa, 100);
}

function waitForKoneContent() {
    let attempts = 0;
    const maxAttempts = 20;
    const checkInterval = setInterval(async () => {
        attempts++;
        await handleBlockingModals(host);

        const atc = getKoneGGContentElement();
        const titleEl = [...document.querySelectorAll('h1.flex, h1.text-xl')].find(el =>
            el.textContent?.match(/RJ[0-9]{6,10}|VJ[0-9]{6,10}/i)
        );

        const hasBase64 = atc && /aHR0c|YUhSMG|WVVoU|V1ZWb/.test(atc.textContent || '');

        if (atc && (titleEl || hasBase64) && (atc.textContent || '').length > 10) {
            clearInterval(checkInterval);
            FindPW();
            setTimeout(() => {
                doDec();
            }, 300);
        } else if (attempts >= maxAttempts) {
            clearInterval(checkInterval);
        } else {
        }
    }, 300);
}


async function aaa() {
    const saved = await GM.getValue('npw');
    if (Array.isArray(saved)) {
        npw = [...new Set([...npw, ...saved])];
    } else {
    }
}


(async () => {
    await chkPW();
    await handleBlockingModals(host);

    if (host === 'arca.live') {
        FindPW();
        setTimeout(doDec, 200);
    } else if (host === 'kone.gg') {
        waitForKoneContent();
    }

    if(host=='kio.ac'){
        await aaa();
        chkp[0]='.overflow-auto.max-w-full.max-h-full.flex-grow.p-1 input:nth-of-type(1)';
        chkp[1]='.flex.flex-col-reverse button:nth-of-type(1)';
        chkp[2]='.p-2.align-middle .flex.align-middle button:nth-of-type(1)';
        isT[2]=true;
        PageLoading[1]=3500;
        setTimeout(inputPW, (PageLoading[0] || 1000) + 2000);
    }
    if(host=='mega.nz'){
        await aaa();
        chkp[0]='#password-decrypt-input';
        chkp[1]='.mega-button.positive.fm-dialog-new-folder-button.decrypt-link-button';
        chkp[2]='.mega-button.positive.js-default-download.js-standard-download';
        PageLoading[1]=4000;
        isT[2]=false;
        setTimeout(inputPW, (PageLoading[0] || 1000) + 1800);
    }
    if(host=='kiosk.ac'){
        await aaa();
        chkp[0]='.input.shadow-xl.flex-grow';
        chkp[1]='.btn.btn-ghost.w-full.mt-2.rounded-md';
        if(Down_Option==2)
            chkp[2]='.flex.justify-between.w-full .flex.gap-2 .btn.btn-ghost';
        else
            chkp[2]='#vexplorer-body .hover\\:bg-neutral .dropdown button, #vexplorer-body > div > div > div.flex.justify-between.w-full > div.flex.gap-2 > button:not(.btn-disabled)';

        if(Down_Option==0)
            isT[2]=true;
        else
            isT[2]=false;
        PageLoading[1]=3000;
        setTimeout(inputPW, (PageLoading[0] || 1000));
    }
    if(host=='workupload.com'){
        await aaa();
        chkp[0]='#passwordprotected_file_password';
        chkp[1]='#passwordprotected_file_submit';
        chkp[2]='a.btn.btn-prio[href*="/file/"]';
        if(Down_Option==0)
            isT[2]=true;
        else
            isT[2]=false;
        PageLoading[1]=2000;
        setTimeout(inputPW, (PageLoading[0] || 1000));
    }
    if(host=='drive.google.com'){
        await aaa();
        if(document.URL.includes('/file/d/')){
            const fileId = document.URL.split('/d/')[1].split('/')[0];
            if (fileId) {
                window.location.href=`https://drive.usercontent.google.com/download?id=${fileId}&export=download&authuser=0`;
            }
        }
        if(document.URL.includes('/drive/folders/')){
            setTimeout(()=> {
                if(isT[0]==true) {
                    const downloadAllButton = document.querySelector('div[aria-label="모두 다운로드"], div[data-tooltip="모두 다운로드"]');
                    if (downloadAllButton) {
                        downloadAllButton.click();
                    } else {
                        const firstItemDownloadButton = document.querySelector('div[role="gridcell"][data-is-shared="false"] div[aria-label*="다운로드"]');
                         if(firstItemDownloadButton) {
                            firstItemDownloadButton.click();
                         }
                    }
                }
            }, (PageLoading[0] || 1000) + 1500);

            chkp[2]='.h-De-Vb.h-De-Y';
            PageLoading[1]=1;
            isT[2]=true;
            setTimeout(()=> { if(isT[0]==true) setTimeout(DBtn, 3500);}, (PageLoading[0] || 1000));
        }
    }
    if(host=='drive.usercontent.google.com'){
        await aaa();
        chkp[2]='form[method="POST"] button[type="submit"], input[type="submit"][value="다운로드"], button.jfk-button-action';
        isT[2]=true;
        setTimeout(()=> { if(isT[0]==true) DBtn();}, 100);
    }
    if(host=='gofile.io'){
        await aaa();
        chkp[0]='#filesErrorPasswordInput';
        chkp[1]='#filesErrorPasswordButton';
        chkp[2]='button.btn-download, a.btn-download, #rowFolderCenter button[data-bs-target="#filesList"] + div .btn-outline-secondary';
        PageLoading[1]=3000;
        isT[2]=true;
        setTimeout(inputPW, (PageLoading[0] || 1000));
    }
})();


(function () {
    'use strict';
    if (location.host !== 'kone.gg') return;

    function hookDecodeTriggerOnButton() {
        const container = document.querySelector('div.flex.items-center.justify-between.p-4');
        if (!container) {
            return;
        }

        const button = container.querySelector('button[data-slot="button"]');
        if (!button) {
            return;
        }
        if (button.dataset._somi_hooked === '1') {
            return;
        }

        button.dataset._somi_hooked = '1';

        button.addEventListener('click', async () => {
            await handleBlockingModals(host);
            setTimeout(() => {
                FindPW();
                setTimeout(() => {
                    doDec();
                }, 300);
            }, 500);
        });
    }

    hookDecodeTriggerOnButton();

    const observer = new MutationObserver(async (mutationsList, obs) => {
        hookDecodeTriggerOnButton();
        await handleBlockingModals(host);
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();

(function () {
    'use strict';
    if (location.host !== 'kone.gg') return;

    let lastUrl = location.href;
    let mainProcessingIntervalId = null;

    const observer = new MutationObserver(async () => {
        const currentUrl = location.href;
        if (currentUrl !== lastUrl) {
            lastUrl = currentUrl;
            if (mainProcessingIntervalId) {
                clearInterval(mainProcessingIntervalId);
            }
            await handleBlockingModals(host);
            observeAndRunKoneFunctions();
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    async function observeAndRunKoneFunctions() {
        const start = Date.now();
        const timeout = 8000;

        if (mainProcessingIntervalId) {
            clearInterval(mainProcessingIntervalId);
        }

        mainProcessingIntervalId = setInterval(async () => {
            await handleBlockingModals(host);
            const atc = getKoneGGContentElement();
            const hasText = atc && (atc.textContent || '').length > 20;
            const hasEncoded = atc && /aHR0c|YUhSMG|WVVoU|V1ZWb/.test(atc.textContent || '');
            const hasDlsiteLink = atc && atc.querySelector('a[href*="dlsite.com"]');

            if (atc && (hasText && (hasEncoded || hasDlsiteLink))) {
                clearInterval(mainProcessingIntervalId);
                mainProcessingIntervalId = null;
                FindPW();
                setTimeout(() => {
                    doDec();
                }, 300);
            }

            if (Date.now() - start > timeout) {
                clearInterval(mainProcessingIntervalId);
                mainProcessingIntervalId = null;
            }
        }, 300);
    }

    (async () => {
        await handleBlockingModals(host);
        observeAndRunKoneFunctions();
    })();
})();