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

  1. // ==UserScript==
  2. // @name Catbox Mod
  3. // @name:ja Catbox Mod
  4. // @namespace https://catbox.moe/
  5. // @version 1.0
  6. // @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
  7. // @description:ja User HomeのView Filesボタンをクリックした際にファイル一覧を最新順で開くようにする, ファイル一覧にURLコピーボタン(📋)を追加
  8. // @match https://catbox.moe/user/*
  9. // @icon https://catbox.moe/favicon.ico
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // View Files link changed to sorted URL (sort by newest)
  18. const link = document.querySelector('a.linkbutton[href="view.php"]');
  19. if (link) {
  20. link.href = "view.php?page=&sortby=newest";
  21. }
  22.  
  23. // Add copy button
  24. const links = document.querySelectorAll('#results a.linkbutton');
  25.  
  26. links.forEach(link => {
  27. const imgUrl = link.href;
  28.  
  29. // create button
  30. const btn = document.createElement('button');
  31. btn.textContent = '📋';
  32. btn.style.marginLeft = '6px';
  33. btn.style.padding = '1px 0 2px';
  34. btn.style.width = '20px';
  35. btn.style.fontSize = '16px';
  36. btn.style.cursor = 'pointer';
  37. btn.style.borderRadius = '4px';
  38. btn.style.background = 'none';
  39. btn.style.border = 'none'
  40.  
  41. // Copy link URL
  42. btn.addEventListener('click', (e) => {
  43. e.preventDefault();
  44. e.stopPropagation();
  45. navigator.clipboard.writeText(imgUrl).then(() => {
  46. btn.textContent = '✅';
  47. setTimeout(() => {btn.textContent = '📋'}, 1000);
  48. });
  49. });
  50.  
  51. // Add button
  52. link.parentNode.insertBefore(btn, link.nextSibling);
  53. });
  54. })();