Catbox Mod

Open the list of files in the latest order when clicking the View Files button in User Home, Added URL copy button (📋) to file list

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name            Catbox Mod
// @name:ja         Catbox Mod
// @namespace       https://catbox.moe/
// @version         1.0
// @description     Open the list of files in the latest order when clicking the View Files button in User Home, Added URL copy button (📋) to file list
// @description:ja  User HomeのView Filesボタンをクリックした際にファイル一覧を最新順で開くようにする, ファイル一覧にURLコピーボタン(📋)を追加
// @match           https://catbox.moe/user/*
// @icon            https://catbox.moe/favicon.ico
// @grant           none
// @license         MIT
// ==/UserScript==

(function () {
    'use strict';

    // View Files link changed to sorted URL (sort by newest)
    const link = document.querySelector('a.linkbutton[href="view.php"]');
    if (link) {
        link.href = "view.php?page=&sortby=newest";
    }

    // Add copy button
    const links = document.querySelectorAll('#results a.linkbutton');

    links.forEach(link => {
        const imgUrl = link.href;

        // create button
        const btn = document.createElement('button');
        btn.textContent = '📋';
        btn.style.marginLeft = '6px';
        btn.style.padding = '1px 0 2px';
        btn.style.width = '20px';
        btn.style.fontSize = '16px';
        btn.style.cursor = 'pointer';
        btn.style.borderRadius = '4px';
        btn.style.background = 'none';
        btn.style.border = 'none'

        // Copy link URL
        btn.addEventListener('click', (e) => {
            e.preventDefault();
            e.stopPropagation();
            navigator.clipboard.writeText(imgUrl).then(() => {
                btn.textContent = '✅';
                setTimeout(() => {btn.textContent = '📋'}, 1000);
            });
        });

        // Add button
        link.parentNode.insertBefore(btn, link.nextSibling);
    });
})();