심야 자동 식당

심챈 자동 복호화/국룰입력/다운(kiosk,mega)

目前為 2024-05-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name		심야 자동 식당
// @namespace	http://tampermonkey.net/
// @version		3.0
// @description	심챈 자동 복호화/국룰입력/다운(kiosk,mega)
// @author		김머시기
// @match		https://kiosk.ac/c/*
// @match		https://arca.live/b/simya*
// @match		https://mega.nz/*
// @icon		https://www.google.com/s2/favicons?sz=64&domain=kioskloud.ac
// @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';
const rpw = atob("c21wZW9wbGU=");
let password = [rpw,"#"+rpw+"#",
//==============================      Settings      ====================================
//    추가하길 원하는 비밀번호 쉼표로 구분해서 바로 아래줄에 따옴표안에 넣으면 됨  ex) "1234","2024국룰","!국룰!"

];
let pageLoadtime = 1200;//    본인 컴퓨터, 인터넷 사양이 좋지 않아 페이지 로딩시간이 오래걸리면 해당 값 조절하세요(1000당 1초)
//======================================================================================
let rpt,pwi,pwb,btd,dtime,autoTab,autoDown,isDown,isTab;
let currentHost = document.URL.split("/")[2];
const timer = ms => new Promise(res => setTimeout(res, ms))
async function rnrfnf() {
    rpt = await GM.getValue("rpt");
    isDown = await GM.getValue("isDown",true);
    isTab = await GM.getValue("isTab",false);
    updateDown();
    updateTab();
    if(currentHost == "arca.live") {
        if(rpt != rpw)	{
            const chk = prompt("국룰 확인");
            if(chk?.toLowerCase() == rpw) {
                await GM.setValue("rpt", rpw);
            } else {
                GM.setValue("rpt", false);
                alert("국룰이 일치하지 않습니다.");
            }
        }
    }
}
let DownId = null, TabId = null;
async function toggleDown() {
    isDown = !isDown;
    if(isDown === false && isTab === true) {
        isTab = false;
        await GM.setValue("isTab",isTab);
    }
    await GM.setValue("isDown",isDown);
    updateDown();
    updateTab();
}
async function toggleTab() {
    isTab = !isTab;
    if(isDown === false && isTab === true) {
        isDown = true;
        await GM.setValue("isDown",isDown);
    }
    await GM.setValue("isTab",isTab);
    updateDown();
    updateTab();
}

function updateDown() {
    if (DownId !== null) GM_unregisterMenuCommand(DownId);
    DownId = GM_registerMenuCommand(`자동 다운로드 ${isDown ? '켜짐' : '꺼짐'}`, toggleDown);
    if(isDown === true) autoDown = "on";
    if(isDown === false) autoDown = "off";
}
function updateTab() {
    if (TabId !== null) GM_unregisterMenuCommand(TabId);
    TabId = GM_registerMenuCommand(`자동 탭 닫기 ${isTab ? '켜짐' : '꺼짐'}`, toggleTab);
    if(isTab === false) autoTab = "off";
    if(isTab === true) autoTab = "on";
}

function doDecode() {
    if(rpt==rpw) {
        const article = document.querySelector("body div.article-body > div.fr-view.article-content");
        function dec(reg) {
            try {
                while (reg.test(article.innerHTML)) {
                    let decoded = reg.exec(article.innerHTML)[0];
                    while (decoded.match(/aHR0c[0-9A-Za-z+/-]{8,}[=]{0,2}/) == null) {
                        decoded = atob(decoded);
                    }
                    decoded = atob(decoded); console.log(decoded);
                    article.innerHTML = article.innerHTML.replace(reg, `<a href=${decoded} target='_blank' rel='noreferrer'>${decoded}</a>`);
                }
            } catch(e) {
                console.log(e,article);
            }
        }
        dec(/aHR0c[0-9A-Za-z+/-]{20,}[=]{0,2}/);
        dec(/YUhSMGN[0-9A-Za-z+/-]{80,}[=]{0,2}/);
        dec(/[0-9A-Za-z+/-]{30,}[=]{1,2}/);
        dec(/[0-9A-Za-z+/-]{200,}[=]{0,2}/);
    }
}
async function pw() {
    if(rpt==rpw) {
        for (var i = 0; i < password.length; i++) {
            document.querySelector(pwi).value = password[i];
            document.querySelector(pwb).click();
            if(i < password.length-1) {
                if(password[i] != null && password[i] != "") await timer(700);
            } else {
                if(autoDown=="on") await setTimeout(dbtn,dtime);
            }
        }
    }
}
async function dbtn() {
	let downBtn = document.querySelector(btd);
    if(currentHost == "mega.nz") {
        let resumeBtn = document.querySelector('.mega-button.positive.resume.js-resume-download');
        await resumeBtn.click();
    }
    await downBtn.click();
    if(downBtn != null && autoTab == "on") setTimeout(() => { window.open('','_self').close(); }, 1000);
}
rnrfnf();
if(currentHost == "arca.live") setTimeout(doDecode, 100);
if(currentHost == "mega.nz") {
    pwi = "#password-decrypt-input";
    pwb = ".mega-button.positive.fm-dialog-new-folder-button.decrypt-link-button";
    btd = ".mega-button.positive.js-default-download.js-standard-download";
    dtime = 4000;
    setTimeout(pw, pageLoadtime+1000);
} if(currentHost == "kiosk.ac") {
    pwi = ".input.shadow-xl.flex-grow";
    pwb = ".btn.btn-ghost.w-full.mt-2.rounded-md";
    btd = ".p-2 li:last-child button";
    dtime = 1000;
    setTimeout(pw, pageLoadtime);
}