M3Unator - Web Directory Playlist Creator

Create M3U/M3U8 playlists from directory listing pages. Automatically finds video and audio files in web server indexes.

目前為 2024-12-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name M3Unator - Web Directory Playlist Creator
  3. // @namespace https://github.com/hasanbeder/M3Unator
  4. // @version 1.0.1
  5. // @description Create M3U/M3U8 playlists from directory listing pages. Automatically finds video and audio files in web server indexes.
  6. // @author Hasan Beder
  7. // @license GPL-3.0
  8. // @match *://*/*
  9. // @grant GM_addStyle
  10. // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWMyZTciIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cG9seWdvbiBwb2ludHM9IjIzIDcgMTYgMTIgMjMgMTcgMjMgNyIvPjxyZWN0IHg9IjEiIHk9IjUiIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNCIgcng9IjIiIHJ5PSIyIi8+PC9zdmc+
  11. // @homepageURL https://github.com/hasanbeder/M3Unator
  12. // @supportURL https://github.com/hasanbeder/M3Unator/issues
  13. // @run-at document-end
  14. // @noframes true
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. if (!document.title.includes('Index of') && !document.querySelector('div#table-list')) {
  21. console.log('This page is not an Index page, M3Unator disabled.');
  22. return;
  23. }
  24.  
  25. function parseLiteSpeedDirectory() {
  26. const links = [];
  27. const rows = document.querySelectorAll('#table-content tr');
  28. rows.forEach(row => {
  29. const linkElement = row.querySelector('a');
  30. if (linkElement && !linkElement.textContent.includes('Parent Directory')) {
  31. const href = linkElement.getAttribute('href');
  32. if (href) {
  33. links.push(new URL(href, window.location.href).href);
  34. }
  35. }
  36. });
  37. return links;
  38. }
  39.  
  40. // Add LiteSpeed support to the existing getDirectoryLinks function
  41. function getDirectoryLinks() {
  42. const links = [];
  43. // LiteSpeed directory listing
  44. if (document.querySelector('div#table-list')) {
  45. const rows = document.querySelectorAll('#table-content tr');
  46. rows.forEach(row => {
  47. const linkElement = row.querySelector('a');
  48. if (linkElement && !linkElement.textContent.includes('Parent Directory')) {
  49. const href = link.getAttribute('href');
  50. if (href) {
  51. links.push(new URL(href, window.location.href).href);
  52. }
  53. }
  54. });
  55. return links;
  56. }
  57. // Apache/Nginx style directory listing
  58. const anchors = document.querySelectorAll('a');
  59. anchors.forEach(anchor => {
  60. if (!anchor.textContent.includes('Parent Directory')) {
  61. const href = anchor.getAttribute('href');
  62. if (href && !href.startsWith('?') && !href.startsWith('/')) {
  63. links.push(new URL(href, window.location.href).href);
  64. }
  65. }
  66. });
  67. return links;
  68. }
  69.  
  70. GM_addStyle(`
  71. @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
  72.  
  73. [class^="M3Unator"] {
  74. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  75. }
  76.  
  77. .M3Unator-title {
  78. font-weight: 700;
  79. letter-spacing: -0.02em;
  80. }
  81.  
  82. .M3Unator-input-group label {
  83. font-weight: 500;
  84. letter-spacing: -0.01em;
  85. }
  86.  
  87. .M3Unator-input {
  88. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  89. font-size: 0.9375rem;
  90. letter-spacing: -0.01em;
  91. }
  92.  
  93. .M3Unator-button {
  94. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  95. font-weight: 600;
  96. letter-spacing: -0.01em;
  97. }
  98.  
  99. .M3Unator-control-btn {
  100. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  101. font-weight: 500;
  102. letter-spacing: -0.01em;
  103. }
  104.  
  105. .M3Unator-log {
  106. font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  107. font-size: 0.8125rem;
  108. letter-spacing: -0.01em;
  109. line-height: 1.5;
  110. }
  111.  
  112. .M3Unator-log-counter {
  113. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  114. font-weight: 600;
  115. letter-spacing: -0.01em;
  116. }
  117.  
  118. .M3Unator-container {
  119. position: fixed;
  120. inset: 0;
  121. background: rgba(0, 0, 0, 0.75);
  122. backdrop-filter: blur(8px);
  123. display: none;
  124. place-items: center;
  125. padding: 1rem;
  126. z-index: 9999;
  127. }
  128.  
  129. .M3Unator-container[data-visible="true"] {
  130. display: grid;
  131. }
  132.  
  133. .M3Unator-overlay {
  134. position: fixed;
  135. inset: 0;
  136. background: transparent;
  137. z-index: 9998;
  138. }
  139.  
  140. body.modal-open {
  141. overflow: hidden;
  142. pointer-events: none; /* Arka plan tıklamalarını engelle */
  143. }
  144.  
  145. body.modal-open .M3Unator-container,
  146. body.modal-open .M3Unator-popup {
  147. pointer-events: all; /* Modal içeriğine tıklamaya izin ver */
  148. }
  149.  
  150. .M3Unator-popup {
  151. background: #11111b;
  152. color: #cdd6f4;
  153. width: 100%;
  154. max-width: 480px;
  155. border-radius: 12px;
  156. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  157. overflow: hidden;
  158. animation: slideUp 0.3s ease;
  159. position: absolute;
  160. }
  161.  
  162. .M3Unator-header {
  163. padding: 1.25rem 1.618rem;
  164. background: #1e1e2e;
  165. color: #cdd6f4;
  166. display: flex;
  167. align-items: center;
  168. justify-content: space-between;
  169. cursor: move;
  170. user-select: none;
  171. border-bottom: 1px solid #313244;
  172. }
  173.  
  174. .M3Unator-title {
  175. display: flex;
  176. align-items: center;
  177. gap: 0.75rem;
  178. margin: 0;
  179. font-size: 1.25rem;
  180. font-weight: 600;
  181. line-height: 1;
  182. }
  183.  
  184. .M3Unator-title svg {
  185. width: 24px;
  186. height: 24px;
  187. color: #f5c2e7;
  188. filter: drop-shadow(0 0 8px rgba(245, 194, 231, 0.4));
  189. flex-shrink: 0;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. margin-top: 1px;
  194. }
  195.  
  196. .M3Unator-title span {
  197. display: flex;
  198. align-items: center;
  199. line-height: 24px;
  200. background: linear-gradient(90deg,
  201. #f5c2e7,
  202. #cba6f7,
  203. #89b4fa,
  204. #a6e3a1,
  205. #f5c2e7
  206. );
  207. background-size: 300% auto;
  208. -webkit-background-clip: text;
  209. background-clip: text;
  210. -webkit-text-fill-color: transparent;
  211. animation: gradient 3s linear infinite;
  212. }
  213.  
  214. .M3Unator-close {
  215. background: rgba(203, 166, 247, 0.1);
  216. border: none;
  217. color: #cba6f7;
  218. width: 32px;
  219. height: 32px;
  220. border-radius: 8px;
  221. display: grid;
  222. place-items: center;
  223. cursor: pointer;
  224. transition: all 0.2s ease;
  225. }
  226.  
  227. .M3Unator-close:hover {
  228. background: rgba(203, 166, 247, 0.2);
  229. transform: rotate(360deg);
  230. }
  231.  
  232. .M3Unator-close svg {
  233. width: 18px;
  234. height: 18px;
  235. }
  236.  
  237. .M3Unator-content {
  238. padding: 0.75rem;
  239. display: flex;
  240. flex-direction: column;
  241. gap: 0.75rem;
  242. }
  243.  
  244. .M3Unator-input-group {
  245. margin-bottom: 0;
  246. }
  247.  
  248. .M3Unator-input-group label {
  249. display: block;
  250. margin-bottom: 0.5rem;
  251. font-weight: 500;
  252. color: #bac2de;
  253. }
  254.  
  255. .M3Unator-input {
  256. width: 100%;
  257. height: 42px; /* Create Playlist butonu ile aynı yükseklik */
  258. padding: 0 12px;
  259. border: 1px solid #45475a;
  260. border-radius: 8px;
  261. background: #1e1e2e;
  262. color: #f5c2e7;
  263. font-size: 14px;
  264. transition: all 0.2s ease;
  265. box-sizing: border-box;
  266. }
  267.  
  268. .M3Unator-input:focus {
  269. outline: none;
  270. border-color: #f5c2e7;
  271. box-shadow: 0 0 0 2px rgba(245, 194, 231, 0.1);
  272. }
  273.  
  274. .M3Unator-input::placeholder {
  275. color: #6c7086;
  276. opacity: 1;
  277. }
  278.  
  279. .M3Unator-toggle-container {
  280. position: relative;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. }
  285.  
  286. .M3Unator-toggle-container input[type="checkbox"] {
  287. display: none;
  288. }
  289.  
  290. .M3Unator-toggle-container span {
  291. width: 48px;
  292. height: 48px;
  293. background: #1e1e2e;
  294. border: 2px solid #45475a;
  295. border-radius: 12px;
  296. display: inline-flex;
  297. align-items: center;
  298. justify-content: center;
  299. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  300. position: relative;
  301. }
  302.  
  303. .M3Unator-toggle-container svg {
  304. width: 24px;
  305. height: 24px;
  306. opacity: 0.7;
  307. transition: all 0.3s ease;
  308. position: absolute;
  309. top: 50%;
  310. left: 50%;
  311. transform: translate(-50%, -50%);
  312. }
  313.  
  314. .M3Unator-toggle-container input[type="checkbox"]:checked + span {
  315. background: rgba(203, 166, 247, 0.1);
  316. border-color: #cba6f7;
  317. box-shadow: 0 0 20px rgba(203, 166, 247, 0.2);
  318. }
  319.  
  320. .M3Unator-toggle-container input[type="checkbox"]:checked + span svg {
  321. opacity: 1;
  322. color: #cba6f7;
  323. filter: drop-shadow(0 0 8px rgba(203, 166, 247, 0.4));
  324. }
  325.  
  326. .M3Unator-toggle-container span:hover {
  327. background: #313244;
  328. transform: translateY(-2px);
  329. }
  330.  
  331. .M3Unator-toggle-container span:active {
  332. transform: translateY(1px);
  333. }
  334.  
  335. .M3Unator-toggle-container input[type="checkbox"]:checked + span:hover {
  336. background: rgba(203, 166, 247, 0.2);
  337. }
  338.  
  339. .M3Unator-toggle-container span:active {
  340. transform: translateY(1px);
  341. }
  342.  
  343. .M3Unator-toggle-container svg {
  344. width: 24px;
  345. height: 24px;
  346. opacity: 0.8;
  347. transition: all 0.2s ease;
  348. }
  349.  
  350. .M3Unator-toggle-container input[type="checkbox"]:checked + span svg {
  351. opacity: 1;
  352. color: #cba6f7;
  353. }
  354.  
  355. .M3Unator-toggle-group {
  356. display: flex;
  357. gap: 0.75rem;
  358. margin: 0.75rem 0;
  359. justify-content: center;
  360. background: rgba(30, 30, 46, 0.4);
  361. padding: 0.75rem;
  362. border-radius: 12px;
  363. backdrop-filter: blur(8px);
  364. }
  365.  
  366. [title]:hover::after {
  367. content: attr(title);
  368. position: absolute;
  369. bottom: calc(100% + 5px);
  370. left: 50%;
  371. transform: translateX(-50%);
  372. padding: 0.5rem 0.75rem;
  373. background: rgba(30, 30, 46, 0.95);
  374. color: #cdd6f4;
  375. font-size: 0.875rem;
  376. white-space: nowrap;
  377. border-radius: 6px;
  378. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  379. z-index: 1000;
  380. border: 1px solid #313244;
  381. text-align: center;
  382. backdrop-filter: blur(8px);
  383. pointer-events: none;
  384. }
  385.  
  386. .M3Unator-button {
  387. width: 100%;
  388. height: 42px;
  389. padding: 0 16px;
  390. border: none;
  391. border-radius: 8px;
  392. background: #f5c2e7;
  393. color: #1e1e2e;
  394. font-weight: 600;
  395. font-size: 14px;
  396. cursor: pointer;
  397. transition: all 0.2s ease;
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. gap: 8px;
  402. }
  403.  
  404. .M3Unator-button:hover {
  405. background: #f5c2e7;
  406. transform: translateY(-1px);
  407. box-shadow: 0 4px 12px rgba(245, 194, 231, 0.2);
  408. }
  409.  
  410. .M3Unator-button:active {
  411. transform: translateY(0);
  412. }
  413.  
  414. .M3Unator-button:disabled {
  415. opacity: 0.5;
  416. cursor: not-allowed;
  417. }
  418.  
  419. .M3Unator-launcher {
  420. position: fixed;
  421. top: 1rem;
  422. right: 1.618rem;
  423. height: 48px;
  424. padding: 0 1.25rem;
  425. border-radius: 12px;
  426. background: rgba(30, 30, 46, 0.95);
  427. border: 2px solid #313244;
  428. cursor: pointer;
  429. box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  430. display: flex;
  431. align-items: center;
  432. gap: 0.75rem;
  433. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  434. z-index: 9998;
  435. backdrop-filter: blur(12px);
  436. }
  437.  
  438. .M3Unator-launcher:hover {
  439. background: rgba(30, 30, 46, 0.98);
  440. border-color: #45475a;
  441. transform: translateY(-2px);
  442. box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  443. }
  444.  
  445. .M3Unator-launcher svg {
  446. width: 24px;
  447. height: 24px;
  448. color: #f5c2e7;
  449. filter: drop-shadow(0 0 8px rgba(245, 194, 231, 0.4));
  450. }
  451.  
  452. .M3Unator-launcher span {
  453. font-weight: 600;
  454. font-size: 0.95rem;
  455. background: linear-gradient(90deg,
  456. #f5c2e7,
  457. #cba6f7,
  458. #89b4fa,
  459. #a6e3a1,
  460. #f5c2e7
  461. );
  462. background-size: 300% auto;
  463. -webkit-background-clip: text;
  464. background-clip: text;
  465. -webkit-text-fill-color: transparent;
  466. animation: gradient 3s linear infinite;
  467. }
  468.  
  469. @keyframes gradient {
  470. 0% { background-position: 0% 50%; filter: hue-rotate(0deg); }
  471. 50% { background-position: 100% 50%; filter: hue-rotate(180deg); }
  472. 100% { background-position: 0% 50%; filter: hue-rotate(360deg); }
  473. }
  474.  
  475. .M3Unator-dropdown {
  476. position: relative;
  477. width: 100%;
  478. }
  479.  
  480. .M3Unator-dropdown-button {
  481. width: 100%;
  482. padding: 0.618rem;
  483. background: #1e1e2e;
  484. border: 1px solid #313244;
  485. border-radius: 8px;
  486. color: #cdd6f4;
  487. font-size: 0.875rem;
  488. text-align: left;
  489. cursor: pointer;
  490. transition: all 0.2s ease;
  491. display: flex;
  492. align-items: center;
  493. justify-content: space-between;
  494. }
  495.  
  496. .M3Unator-dropdown-button:hover {
  497. border-color: #45475a;
  498. background: rgba(30, 30, 46, 0.8);
  499. }
  500.  
  501. .M3Unator-dropdown-button svg {
  502. width: 16px;
  503. height: 16px;
  504. min-width: 16px;
  505. min-height: 16px;
  506. transition: transform 0.2s ease;
  507. }
  508.  
  509. .M3Unator-dropdown.active .M3Unator-dropdown-button {
  510. border-color: #cba6f7;
  511. border-radius: 8px 8px 0 0;
  512. }
  513.  
  514. .M3Unator-dropdown.active .M3Unator-dropdown-button svg {
  515. transform: rotate(180deg);
  516. }
  517.  
  518. .M3Unator-dropdown-menu {
  519. position: absolute;
  520. top: 100%;
  521. left: 0;
  522. right: 0;
  523. background: #1e1e2e;
  524. border: 1px solid #cba6f7;
  525. border-top: none;
  526. border-radius: 0 0 8px 8px;
  527. overflow: hidden;
  528. z-index: 1000;
  529. display: none;
  530. animation: dropdownSlide 0.2s ease;
  531. user-select: none;
  532. }
  533.  
  534. .M3Unator-dropdown.active .M3Unator-dropdown-menu {
  535. display: block;
  536. }
  537.  
  538. .M3Unator-dropdown-item {
  539. padding: 0.618rem;
  540. color: #cdd6f4;
  541. cursor: pointer;
  542. transition: all 0.2s ease;
  543. user-select: none;
  544. }
  545.  
  546. .M3Unator-dropdown-item:hover {
  547. background: rgba(203, 166, 247, 0.1);
  548. }
  549.  
  550. .M3Unator-dropdown-item.selected {
  551. background: rgba(203, 166, 247, 0.1);
  552. color: #cba6f7;
  553. }
  554.  
  555. @keyframes slideUp {
  556. from { transform: translateY(20px); opacity: 0; }
  557. to { transform: translateY(0); opacity: 1; }
  558. }
  559.  
  560. .M3Unator-log {
  561. margin-top: 0.75rem;
  562. max-height: calc(100vh - 70vh);
  563. font-size: 0.8125rem;
  564. line-height: 1.4;
  565. }
  566.  
  567. .M3Unator-log:empty {
  568. display: none;
  569. }
  570.  
  571. .M3Unator-log-entry {
  572. padding: 0.25rem 0.5rem;
  573. border-bottom: 1px solid #313244;
  574. }
  575.  
  576. .M3Unator-log-entry:last-child {
  577. border-bottom: none;
  578. }
  579.  
  580. .M3Unator-log-entry.success {
  581. color: #94e2d5;
  582. }
  583.  
  584. .M3Unator-log-entry.error {
  585. color: #f38ba8;
  586. }
  587.  
  588. .M3Unator-log-entry.warning {
  589. color: #fab387;
  590. }
  591.  
  592. .M3Unator-log-counter {
  593. display: inline-flex;
  594. align-items: center;
  595. justify-content: center;
  596. background: rgba(245, 194, 231, 0.1);
  597. color: #f5c2e7;
  598. padding: 0.25rem 0.75rem;
  599. border-radius: 8px;
  600. font-size: 0.875rem;
  601. font-weight: 500;
  602. margin-left: 0.75rem;
  603. min-width: 3rem;
  604. text-align: center;
  605. }
  606.  
  607. @keyframes gradient {
  608. 0% { background-position: 0% 50%; filter: hue-rotate(0deg); }
  609. 50% { background-position: 100% 50%; filter: hue-rotate(180deg); }
  610. 100% { background-position: 0% 50%; filter: hue-rotate(360deg); }
  611. }
  612.  
  613. .M3Unator-title span.text {
  614. display: inline-block;
  615. position: relative;
  616. padding: 0 0.25rem;
  617. }
  618.  
  619. .M3Unator-title.scanning span.text {
  620. background: linear-gradient(90deg,
  621. #f5c2e7,
  622. #cba6f7,
  623. #89b4fa,
  624. #a6e3a1,
  625. #f5c2e7
  626. );
  627. background-size: 300% auto;
  628. -webkit-background-clip: text;
  629. background-clip: text;
  630. -webkit-text-fill-color: transparent;
  631. animation: gradient 3s linear infinite;
  632. font-weight: 700;
  633. letter-spacing: 0.5px;
  634. }
  635.  
  636. .M3Unator-title.scanning span.text::after {
  637. content: '';
  638. position: absolute;
  639. bottom: -2px;
  640. left: 0;
  641. width: 100%;
  642. height: 2px;
  643. background: inherit;
  644. animation: gradient 3s linear infinite;
  645. }
  646.  
  647. .M3Unator-title.scanning svg {
  648. animation: morphAnimation 2s ease-in-out infinite;
  649. filter: drop-shadow(0 0 8px rgba(203, 166, 247, 0.5));
  650. }
  651.  
  652. @keyframes morphAnimation {
  653. 0% {
  654. transform: scale(1);
  655. opacity: 1;
  656. }
  657. 50% {
  658. transform: scale(1.2);
  659. opacity: 0.7;
  660. }
  661. 100% {
  662. transform: scale(1);
  663. opacity: 1;
  664. }
  665. }
  666.  
  667. .M3Unator-controls {
  668. display: none;
  669. gap: 0.75rem;
  670. margin: 0.75rem 0;
  671. justify-content: center;
  672. }
  673.  
  674. .M3Unator-controls.active {
  675. display: flex;
  676. }
  677.  
  678. .M3Unator-control-btn {
  679. display: none;
  680. padding: 0.75rem 1.5rem;
  681. border-radius: 12px;
  682. font-weight: 600;
  683. font-size: 0.95rem;
  684. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  685. align-items: center;
  686. gap: 0.75rem;
  687. min-width: 160px;
  688. justify-content: center;
  689. background: rgba(30, 30, 46, 0.6);
  690. backdrop-filter: blur(8px);
  691. width: 160px;
  692. }
  693.  
  694. .M3Unator-control-btn:hover {
  695. background: #313244;
  696. transform: translateY(-1px);
  697. }
  698.  
  699. .M3Unator-control-btn:active {
  700. transform: translateY(1px);
  701. }
  702.  
  703. .M3Unator-control-btn.pause {
  704. border-color: #fab387;
  705. color: #fab387;
  706. }
  707.  
  708. .M3Unator-control-btn.pause:hover {
  709. background: rgba(250, 179, 135, 0.1);
  710. }
  711.  
  712. .M3Unator-control-btn.resume {
  713. border-color: #94e2d5;
  714. color: #94e2d5;
  715. }
  716.  
  717. .M3Unator-control-btn.resume:hover {
  718. background: rgba(148, 226, 213, 0.1);
  719. }
  720.  
  721. .M3Unator-control-btn.cancel {
  722. border-color: #f38ba8;
  723. color: #f38ba8;
  724. }
  725.  
  726. .M3Unator-control-btn.cancel:hover {
  727. background: rgba(243, 139, 168, 0.1);
  728. }
  729.  
  730. .M3Unator-control-btn svg {
  731. width: 14px;
  732. height: 14px;
  733. }
  734.  
  735. .M3Unator-button {
  736. width: 100%;
  737. padding: 0 1rem;
  738. background: #f5c2e7;
  739. color: #11111b;
  740. border: none;
  741. border-radius: 6px;
  742. font-weight: 600;
  743. font-size: 0.875rem;
  744. cursor: pointer;
  745. transition: all 0.2s ease;
  746. display: flex;
  747. align-items: center;
  748. justify-content: center;
  749. gap: 0.375rem;
  750. height: 48px;
  751. min-height: 48px;
  752. line-height: 1;
  753. }
  754.  
  755. .M3Unator-spinner {
  756. width: 20px;
  757. height: 20px;
  758. border: 2px solid rgba(17, 17, 27, 0.3);
  759. border-radius: 50%;
  760. border-top-color: #11111b;
  761. animation: spin 0.6s linear infinite;
  762. margin-right: 0;
  763. flex-shrink: 0;
  764. }
  765.  
  766. .M3Unator-toast-container {
  767. position: fixed;
  768. bottom: 24px;
  769. right: 24px;
  770. z-index: 100002;
  771. }
  772.  
  773. .M3Unator-toast {
  774. display: flex;
  775. align-items: center;
  776. gap: 8px;
  777. padding: 12px 16px;
  778. border-radius: 12px;
  779. margin-top: 8px;
  780. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  781. font-size: 14px;
  782. font-weight: 500;
  783. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  784. animation: toastIn 0.3s ease;
  785. background: #1e1e2e;
  786. border: 2px solid;
  787. }
  788.  
  789. .M3Unator-toast.success {
  790. color: #a6e3a1;
  791. border-color: #a6e3a1;
  792. }
  793.  
  794. .M3Unator-toast.error {
  795. color: #f38ba8;
  796. border-color: #f38ba8;
  797. }
  798.  
  799. .M3Unator-toast.warning {
  800. color: #fab387;
  801. border-color: #fab387;
  802. }
  803.  
  804. .M3Unator-toast.removing {
  805. animation: toastOut 0.3s ease forwards;
  806. }
  807.  
  808. @keyframes toastIn {
  809. from {
  810. transform: translateX(100%);
  811. opacity: 0;
  812. }
  813. to {
  814. transform: translateX(0);
  815. opacity: 1;
  816. }
  817. }
  818.  
  819. @keyframes toastOut {
  820. from {
  821. transform: translateX(0);
  822. opacity: 1;
  823. }
  824. to {
  825. transform: translateX(100%);
  826. opacity: 0;
  827. }
  828. }
  829.  
  830. .M3Unator-toast svg {
  831. width: 20px;
  832. height: 20px;
  833. flex-shrink: 0;
  834. }
  835.  
  836. .M3Unator-input-row {
  837. display: flex;
  838. gap: 0.75rem;
  839. margin-bottom: 0.75rem;
  840. }
  841.  
  842. .M3Unator-input-row .M3Unator-input-group {
  843. margin-bottom: 0;
  844. }
  845.  
  846. .M3Unator-input-row .M3Unator-input-group:first-child {
  847. flex: 2;
  848. }
  849.  
  850. .M3Unator-input-row .M3Unator-input-group:last-child {
  851. flex: 1;
  852. }
  853.  
  854. .M3Unator-social {
  855. display: flex;
  856. gap: 8px;
  857. margin-right: 8px;
  858. }
  859.  
  860. .M3Unator-social a {
  861. width: 32px;
  862. height: 32px;
  863. border-radius: 8px;
  864. display: grid;
  865. place-items: center;
  866. color: #cdd6f4;
  867. background: rgba(205, 214, 244, 0.1);
  868. transition: all 0.2s ease;
  869. }
  870.  
  871. .M3Unator-social a:hover {
  872. background: rgba(205, 214, 244, 0.2);
  873. transform: rotate(360deg);
  874. }
  875.  
  876. .M3Unator-social svg {
  877. width: 18px;
  878. height: 18px;
  879. }
  880.  
  881. .M3Unator-advanced-settings {
  882. margin-top: 1rem;
  883. padding: 1rem;
  884. background: rgba(30, 30, 46, 0.5);
  885. border: 1px solid #313244;
  886. border-radius: 8px;
  887. display: none;
  888. }
  889.  
  890. .M3Unator-advanced-settings.active {
  891. display: block;
  892. animation: fadeIn 0.3s ease;
  893. }
  894.  
  895. .M3Unator-advanced-toggle {
  896. width: 100%;
  897. padding: 0.75rem;
  898. background: #1e1e2e;
  899. border: 1px solid #313244;
  900. border-radius: 8px;
  901. color: #cdd6f4;
  902. font-size: 0.875rem;
  903. font-weight: 500;
  904. cursor: pointer;
  905. display: flex;
  906. align-items: center;
  907. justify-content: space-between;
  908. transition: all 0.2s ease;
  909. }
  910.  
  911. .M3Unator-advanced-toggle:hover {
  912. background: #313244;
  913. }
  914.  
  915. .M3Unator-advanced-toggle svg {
  916. width: 16px;
  917. height: 16px;
  918. transition: transform 0.2s ease;
  919. }
  920.  
  921. .M3Unator-advanced-toggle.active svg {
  922. transform: rotate(180deg);
  923. }
  924.  
  925. .M3Unator-depth-slider {
  926. -webkit-appearance: none;
  927. width: 100%;
  928. height: 4px;
  929. border-radius: 2px;
  930. background: #313244;
  931. outline: none;
  932. margin: 1rem 0;
  933. }
  934.  
  935. .M3Unator-depth-slider::-webkit-slider-thumb {
  936. -webkit-appearance: none;
  937. appearance: none;
  938. width: 16px;
  939. height: 16px;
  940. border-radius: 50%;
  941. background: #cba6f7;
  942. cursor: pointer;
  943. transition: all 0.2s ease;
  944. }
  945.  
  946. .M3Unator-depth-slider::-webkit-slider-thumb:hover {
  947. transform: scale(1.2);
  948. }
  949.  
  950. .M3Unator-depth-value {
  951. text-align: center;
  952. font-size: 0.875rem;
  953. color: #cdd6f4;
  954. margin-top: 0.5rem;
  955. }
  956.  
  957. @keyframes fadeIn {
  958. from { opacity: 0; transform: translateY(-10px); }
  959. to { opacity: 1; transform: translateY(0); }
  960. }
  961.  
  962. .M3Unator-depth-settings {
  963. margin-top: 0.75rem;
  964. margin-left: 1.75rem;
  965. padding: 0.75rem;
  966. background: rgba(30, 30, 46, 0.3);
  967. border-left: 2px solid #cba6f7;
  968. border-radius: 0 8px 8px 0;
  969. display: none;
  970. animation: slideDown 0.3s ease;
  971. }
  972.  
  973. .M3Unator-depth-settings.active {
  974. display: block;
  975. }
  976.  
  977. .M3Unator-depth-input {
  978. position: relative;
  979. display: flex;
  980. align-items: center;
  981. gap: 0.75rem;
  982. margin-top: 0.5rem;
  983. }
  984.  
  985. .M3Unator-depth-input input[type="number"] {
  986. width: 64px;
  987. padding: 0.25rem 0.375rem;
  988. border: 1px solid #45475a;
  989. border-radius: 4px;
  990. background: rgba(30, 30, 46, 0.8);
  991. color: #cdd6f4;
  992. font-size: 0.875rem;
  993. text-align: center;
  994. margin: 0 0 0 0.5rem;
  995. }
  996.  
  997. .M3Unator-depth-input input[type="number"]:focus {
  998. outline: none;
  999. border-color: #cba6f7;
  1000. box-shadow: 0 0 0 2px rgba(203, 166, 247, 0.2);
  1001. }
  1002.  
  1003. .M3Unator-depth-input input[type="number"]::-webkit-inner-spin-button {
  1004. opacity: 1;
  1005. background: #313244;
  1006. border-left: 1px solid #45475a;
  1007. border-radius: 0 4px 4px 0;
  1008. cursor: pointer;
  1009. }
  1010.  
  1011. .M3Unator-depth-toggle {
  1012. display: flex;
  1013. align-items: center;
  1014. gap: 0.5rem;
  1015. padding: 0.5rem;
  1016. background: #1e1e2e;
  1017. border: 1px solid #45475a;
  1018. border-radius: 6px;
  1019. color: #cdd6f4;
  1020. font-size: 0.875rem;
  1021. cursor: pointer;
  1022. transition: all 0.2s ease;
  1023. }
  1024.  
  1025. .M3Unator-depth-toggle:hover {
  1026. background: #313244;
  1027. border-color: #cba6f7;
  1028. }
  1029.  
  1030. .M3Unator-depth-toggle.active {
  1031. background: rgba(203, 166, 247, 0.1);
  1032. border-color: #cba6f7;
  1033. color: #cba6f7;
  1034. }
  1035.  
  1036. @keyframes slideDown {
  1037. from { opacity: 0; transform: translateY(-10px); }
  1038. to { opacity: 1; transform: translateY(0); }
  1039. }
  1040.  
  1041. .M3Unator-stats-bar {
  1042. margin: 0.75rem 0;
  1043. padding: 0.5rem;
  1044. background: rgba(30, 30, 46, 0.5);
  1045. border: 1px solid #313244;
  1046. border-radius: 8px;
  1047. display: none;
  1048. }
  1049.  
  1050. .M3Unator-stats-bar.active {
  1051. display: block;
  1052. }
  1053.  
  1054. .M3Unator-stats {
  1055. display: flex;
  1056. align-items: center;
  1057. justify-content: space-around;
  1058. gap: 0.382rem;
  1059. padding: 0.25rem;
  1060. }
  1061.  
  1062. .M3Unator-stat {
  1063. display: inline-flex;
  1064. align-items: center;
  1065. gap: 0.25rem;
  1066. font-size: 0.75rem;
  1067. color: #cdd6f4;
  1068. cursor: help;
  1069. min-width: 40px;
  1070. justify-content: flex-start;
  1071. padding: 0 0.25rem;
  1072. position: relative;
  1073. }
  1074.  
  1075. .M3Unator-stat span {
  1076. min-width: 16px;
  1077. text-align: right;
  1078. font-variant-numeric: tabular-nums;
  1079. font-size: 0.7rem;
  1080. font-weight: 500;
  1081. }
  1082.  
  1083. .M3Unator-stat svg {
  1084. opacity: 0.8;
  1085. flex-shrink: 0;
  1086. width: 14px;
  1087. height: 14px;
  1088. }
  1089.  
  1090. .M3Unator-stat.video {
  1091. color: #94e2d5;
  1092. }
  1093.  
  1094. .M3Unator-stat.audio {
  1095. color: #89b4fa;
  1096. }
  1097.  
  1098. .M3Unator-stat.dir {
  1099. color: #cba6f7;
  1100. }
  1101.  
  1102. .M3Unator-stat.error {
  1103. color: #f38ba8;
  1104. }
  1105.  
  1106. .M3Unator-stat.depth {
  1107. color: #a6e3a1;
  1108. transition: color 0.3s ease;
  1109. }
  1110.  
  1111. .M3Unator-stat.depth[data-progress="high"] {
  1112. color: #f38ba8;
  1113. }
  1114.  
  1115. .M3Unator-stat.depth[data-progress="medium"] {
  1116. color: #fab387;
  1117. }
  1118.  
  1119. .M3Unator-stat.depth[data-progress="low"] {
  1120. color: #f9e2af;
  1121. }
  1122.  
  1123. .M3Unator-stat:hover::after {
  1124. content: attr(title);
  1125. position: absolute;
  1126. bottom: calc(100% + 5px);
  1127. left: 50%;
  1128. transform: translateX(-50%);
  1129. padding: 0.5rem 0.75rem;
  1130. background: rgba(30, 30, 46, 0.95);
  1131. color: #cdd6f4;
  1132. font-size: 0.875rem;
  1133. white-space: nowrap;
  1134. border-radius: 6px;
  1135. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  1136. z-index: 1000;
  1137. border: 1px solid #313244;
  1138. text-align: center;
  1139. backdrop-filter: blur(8px);
  1140. pointer-events: none;
  1141. }
  1142.  
  1143. .M3Unator-spinner {
  1144. width: 20px;
  1145. height: 20px;
  1146. border: 2px solid rgba(17, 17, 27, 0.3);
  1147. border-radius: 50%;
  1148. border-top-color: #11111b;
  1149. animation: spin 0.6s linear infinite;
  1150. margin-right: 0;
  1151. flex-shrink: 0;
  1152. }
  1153.  
  1154. @keyframes spin {
  1155. to { transform: rotate(360deg); }
  1156. }
  1157.  
  1158. .M3Unator-toast {
  1159. animation: toastSlideUp 0.2s ease forwards;
  1160. }
  1161.  
  1162. .M3Unator-toast.removing {
  1163. animation: toastSlideDown 0.2s ease forwards;
  1164. }
  1165.  
  1166. .M3Unator-popup {
  1167. animation: slideUp 0.2s ease;
  1168. }
  1169.  
  1170. .M3Unator-stats-bar {
  1171. animation: fadeIn 0.2s ease;
  1172. }
  1173.  
  1174. .M3Unator-log {
  1175. transition: max-height 0.3s ease;
  1176. }
  1177.  
  1178. .M3Unator-log.collapsed {
  1179. max-height: 0;
  1180. overflow: hidden;
  1181. }
  1182.  
  1183. .M3Unator-log-toggle {
  1184. width: 100%;
  1185. padding: 0.75rem;
  1186. background: #1e1e2e;
  1187. border: none;
  1188. color: #cdd6f4;
  1189. display: flex;
  1190. align-items: center;
  1191. justify-content: center;
  1192. gap: 0.75rem;
  1193. cursor: pointer;
  1194. transition: all 0.2s ease;
  1195. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  1196. }
  1197.  
  1198. .M3Unator-log-toggle:hover {
  1199. background: rgba(30, 30, 46, 0.8);
  1200. }
  1201.  
  1202. .M3Unator-log-toggle svg {
  1203. width: 20px;
  1204. height: 20px;
  1205. flex-shrink: 0;
  1206. }
  1207.  
  1208. .M3Unator-log-toggle.active svg {
  1209. transform: rotate(180deg);
  1210. }
  1211.  
  1212. .M3Unator-toggle-container span svg .infinity-icon {
  1213. opacity: 0.5;
  1214. transition: opacity 0.2s ease;
  1215. transform: scale(0.6) translateY(4px);
  1216. transform-origin: center;
  1217. stroke-width: 1.5;
  1218. }
  1219.  
  1220. .M3Unator-toggle-container input[type="checkbox"]:checked + span svg .infinity-icon {
  1221. opacity: 1;
  1222. }
  1223.  
  1224. .M3Unator-depth-controls {
  1225. background: rgba(30, 30, 46, 0.4);
  1226. backdrop-filter: blur(8px);
  1227. border: 1px solid #313244;
  1228. border-radius: 8px;
  1229. padding: 0.618rem;
  1230. margin-top: 1rem;
  1231. display: none;
  1232. }
  1233.  
  1234. .M3Unator-depth-controls.active {
  1235. display: block;
  1236. }
  1237.  
  1238. .M3Unator-radio-group {
  1239. display: flex;
  1240. gap: 0.75rem;
  1241. justify-content: center;
  1242. background: rgba(30, 30, 46, 0.6);
  1243. padding: 0.5rem;
  1244. border-radius: 6px;
  1245. }
  1246.  
  1247. .M3Unator-radio {
  1248. display: flex;
  1249. align-items: center;
  1250. gap: 0.5rem;
  1251. cursor: pointer;
  1252. padding: 0.5rem;
  1253. border-radius: 4px;
  1254. transition: all 0.2s ease;
  1255. background: transparent;
  1256. border: 1px solid transparent;
  1257. }
  1258.  
  1259. .M3Unator-radio:hover {
  1260. background: rgba(203, 166, 247, 0.1);
  1261. }
  1262.  
  1263. .M3Unator-radio input[type="radio"] {
  1264. display: none;
  1265. }
  1266.  
  1267. .M3Unator-radio .radio-mark {
  1268. width: 16px;
  1269. height: 16px;
  1270. border: 1.5px solid #45475a;
  1271. border-radius: 50%;
  1272. display: flex;
  1273. align-items: center;
  1274. justify-content: center;
  1275. transition: all 0.2s ease;
  1276. flex-shrink: 0;
  1277. background: rgba(30, 30, 46, 0.6);
  1278. position: relative;
  1279. }
  1280.  
  1281. .M3Unator-radio input[type="radio"]:checked + .radio-mark {
  1282. border-color: #cba6f7;
  1283. background: rgba(203, 166, 247, 0.1);
  1284. }
  1285.  
  1286. .M3Unator-radio input[type="radio"]:checked + .radio-mark::after {
  1287. content: '';
  1288. width: 8px;
  1289. height: 8px;
  1290. border-radius: 50%;
  1291. background: #cba6f7;
  1292. position: absolute;
  1293. }
  1294.  
  1295. .M3Unator-radio .radio-label {
  1296. color: #cdd6f4;
  1297. font-size: 0.875rem;
  1298. user-select: none;
  1299. display: flex;
  1300. align-items: center;
  1301. gap: 0.5rem;
  1302. }
  1303.  
  1304. .M3Unator-depth-input {
  1305. width: 64px;
  1306. padding: 0.25rem 0.375rem;
  1307. border: 1px solid #45475a;
  1308. border-radius: 4px;
  1309. background: rgba(30, 30, 46, 0.8);
  1310. color: #cdd6f4;
  1311. font-size: 0.875rem;
  1312. text-align: center;
  1313. transition: all 0.2s ease;
  1314. -moz-appearance: textfield;
  1315. margin-top: -1px;
  1316. display: inline-flex;
  1317. align-items: center;
  1318. height: 28px;
  1319. }
  1320.  
  1321. .M3Unator-depth-input::-webkit-outer-spin-button,
  1322. .M3Unator-depth-input::-webkit-inner-spin-button {
  1323. -webkit-appearance: inner-spin-button;
  1324. opacity: 1;
  1325. background: #313244;
  1326. border-left: 1px solid #45475a;
  1327. border-radius: 0 4px 4px 0;
  1328. cursor: pointer;
  1329. height: 100%;
  1330. position: absolute;
  1331. right: 0;
  1332. top: 0;
  1333. }
  1334.  
  1335. .M3Unator-depth-input:focus {
  1336. outline: none;
  1337. border-color: #cba6f7;
  1338. box-shadow: 0 0 0 2px rgba(203, 166, 247, 0.2);
  1339. }
  1340.  
  1341. .M3Unator-depth-input:disabled {
  1342. opacity: 0.5;
  1343. cursor: not-allowed;
  1344. background: rgba(30, 30, 46, 0.4);
  1345. }
  1346.  
  1347. .M3Unator-radio .radio-label {
  1348. display: flex;
  1349. align-items: center;
  1350. gap: 0.5rem;
  1351. color: #cdd6f4;
  1352. font-size: 0.875rem;
  1353. user-select: none;
  1354. }
  1355.  
  1356. .M3Unator-url-container {
  1357. display: flex;
  1358. align-items: center;
  1359. background: rgba(30, 30, 46, 0.6);
  1360. border: 1px solid #313244;
  1361. border-radius: 6px;
  1362. padding: 0.618rem;
  1363. margin-bottom: 1rem;
  1364. transition: all 0.2s ease;
  1365. }
  1366.  
  1367. .M3Unator-url-container:hover {
  1368. border-color: #45475a;
  1369. }
  1370.  
  1371. .M3Unator-url-icon {
  1372. color: #6c7086;
  1373. margin-right: 0.618rem;
  1374. flex-shrink: 0;
  1375. }
  1376.  
  1377. .M3Unator-url-input {
  1378. flex: 1;
  1379. background: transparent;
  1380. border: none;
  1381. color: #cdd6f4;
  1382. font-size: 0.875rem;
  1383. padding: 0;
  1384. margin: 0;
  1385. width: 100%;
  1386. }
  1387.  
  1388. .M3Unator-url-input:focus {
  1389. outline: none;
  1390. }
  1391.  
  1392. .M3Unator-url-copy {
  1393. background: transparent;
  1394. border: none;
  1395. color: #6c7086;
  1396. padding: 0.382rem;
  1397. margin-left: 0.618rem;
  1398. cursor: pointer;
  1399. border-radius: 4px;
  1400. transition: all 0.2s ease;
  1401. display: flex;
  1402. align-items: center;
  1403. justify-content: center;
  1404. }
  1405.  
  1406. .M3Unator-url-copy:hover {
  1407. color: #cdd6f4;
  1408. background: rgba(205, 214, 244, 0.1);
  1409. }
  1410.  
  1411. .M3Unator-url-copy.copied {
  1412. color: #a6e3a1;
  1413. animation: copyPulse 0.3s ease;
  1414. }
  1415.  
  1416. @keyframes copyPulse {
  1417. 0% { transform: scale(1); }
  1418. 50% { transform: scale(1.2); }
  1419. 100% { transform: scale(1); }
  1420. }
  1421.  
  1422. .M3Unator-toggle-group {
  1423. display: flex;
  1424. gap: 1.25rem;
  1425. margin: 1.5rem 0;
  1426. justify-content: center;
  1427. background: rgba(30, 30, 46, 0.4);
  1428. padding: 1.25rem;
  1429. border-radius: 16px;
  1430. backdrop-filter: blur(8px);
  1431. }
  1432.  
  1433. .M3Unator-toggle-container {
  1434. position: relative;
  1435. }
  1436.  
  1437. .M3Unator-toggle-container span {
  1438. width: 64px;
  1439. height: 64px;
  1440. background: #1e1e2e;
  1441. border: 2px solid #45475a;
  1442. border-radius: 16px;
  1443. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  1444. display: flex;
  1445. align-items: center;
  1446. justify-content: center;
  1447. }
  1448.  
  1449. .M3Unator-toggle-container input[type="checkbox"]:checked + span {
  1450. background: rgba(203, 166, 247, 0.1);
  1451. border-color: #cba6f7;
  1452. box-shadow: 0 0 20px rgba(203, 166, 247, 0.2);
  1453. transform: translateY(-2px);
  1454. }
  1455.  
  1456. .M3Unator-toggle-container span:hover {
  1457. background: #313244;
  1458. transform: translateY(-2px);
  1459. box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  1460. }
  1461.  
  1462. .M3Unator-toggle-container svg {
  1463. width: 32px;
  1464. height: 32px;
  1465. opacity: 0.7;
  1466. transition: all 0.3s ease;
  1467. }
  1468.  
  1469. .M3Unator-toggle-container input[type="checkbox"]:checked + span svg {
  1470. opacity: 1;
  1471. color: #cba6f7;
  1472. filter: drop-shadow(0 0 8px rgba(203, 166, 247, 0.4));
  1473. }
  1474.  
  1475. .M3Unator-progress {
  1476. background: rgba(30, 30, 46, 0.6);
  1477. border-radius: 12px;
  1478. padding: 1rem;
  1479. margin: 1rem 0;
  1480. backdrop-filter: blur(8px);
  1481. border: 1px solid rgba(203, 166, 247, 0.2);
  1482. }
  1483.  
  1484. .M3Unator-progress-text {
  1485. color: #f5c2e7;
  1486. font-weight: 600;
  1487. text-align: center;
  1488. margin-bottom: 0.5rem;
  1489. font-size: 1.1rem;
  1490. }
  1491.  
  1492. .M3Unator-progress-spinner {
  1493. width: 24px;
  1494. height: 24px;
  1495. border: 3px solid rgba(245, 194, 231, 0.1);
  1496. border-top-color: #f5c2e7;
  1497. border-radius: 50%;
  1498. animation: spin 1s linear infinite;
  1499. margin: 0 auto;
  1500. }
  1501.  
  1502. .M3Unator-controls {
  1503. display: flex;
  1504. gap: 0.75rem;
  1505. margin: 0.75rem 0;
  1506. justify-content: center;
  1507. }
  1508.  
  1509. .M3Unator-control-btn {
  1510. display: none;
  1511. padding: 0.75rem 1.5rem;
  1512. border-radius: 12px;
  1513. font-weight: 600;
  1514. font-size: 0.95rem;
  1515. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  1516. align-items: center;
  1517. gap: 0.75rem;
  1518. min-width: 160px;
  1519. justify-content: center;
  1520. background: rgba(30, 30, 46, 0.6);
  1521. backdrop-filter: blur(8px);
  1522. width: 160px;
  1523. }
  1524.  
  1525. .M3Unator-control-btn.pause {
  1526. background: rgba(250, 179, 135, 0.1);
  1527. border: 2px solid #fab387;
  1528. color: #fab387;
  1529. }
  1530.  
  1531. .M3Unator-control-btn.resume {
  1532. background: rgba(148, 226, 213, 0.1);
  1533. border: 2px solid #94e2d5;
  1534. color: #94e2d5;
  1535. }
  1536.  
  1537. .M3Unator-control-btn.cancel {
  1538. background: rgba(243, 139, 168, 0.1);
  1539. border: 2px solid #f38ba8;
  1540. color: #f38ba8;
  1541. }
  1542.  
  1543. .M3Unator-control-btn:hover {
  1544. transform: translateY(-2px);
  1545. box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  1546. }
  1547.  
  1548. .M3Unator-control-btn svg {
  1549. width: 20px;
  1550. height: 20px;
  1551. }
  1552.  
  1553. .M3Unator-layers-icon {
  1554. width: 20px;
  1555. height: 20px;
  1556. margin-right: 0.5rem;
  1557. }
  1558.  
  1559. .M3Unator-input:-webkit-autofill,
  1560. .M3Unator-input:-webkit-autofill:hover,
  1561. .M3Unator-input:-webkit-autofill:focus,
  1562. .M3Unator-input:-webkit-autofill:active {
  1563. -webkit-text-fill-color: #cdd6f4 !important;
  1564. -webkit-box-shadow: 0 0 0 30px #1e1e2e inset !important;
  1565. box-shadow: 0 0 0 30px #1e1e2e inset !important;
  1566. background-color: #1e1e2e !important;
  1567. color: #cdd6f4 !important;
  1568. caret-color: #cdd6f4 !important;
  1569. transition: background-color 5000s ease-in-out 0s !important;
  1570. text-decoration: none !important;
  1571. -webkit-text-decoration: none !important;
  1572. }
  1573.  
  1574. .M3Unator-input:-moz-autofill,
  1575. .M3Unator-input:-moz-autofill-preview {
  1576. background-color: #1e1e2e !important;
  1577. color: #cdd6f4 !important;
  1578. text-decoration: none !important;
  1579. }
  1580.  
  1581. .M3Unator-input:-ms-input-placeholder {
  1582. background-color: #1e1e2e !important;
  1583. color: #cdd6f4 !important;
  1584. text-decoration: none !important;
  1585. }
  1586.  
  1587. .M3Unator-log-container {
  1588. margin: 0;
  1589. }
  1590.  
  1591. .M3Unator-log-toggle {
  1592. width: 100%;
  1593. padding: 0.5rem 0.75rem;
  1594. background: rgba(203, 166, 247, 0.05);
  1595. border: none;
  1596. color: #cdd6f4;
  1597. display: flex;
  1598. align-items: center;
  1599. justify-content: space-between;
  1600. cursor: pointer;
  1601. transition: all 0.2s ease;
  1602. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  1603. font-size: 0.875rem;
  1604. font-weight: 500;
  1605. border-radius: 6px;
  1606. }
  1607.  
  1608. .M3Unator-log-toggle:hover {
  1609. background: rgba(203, 166, 247, 0.1);
  1610. }
  1611.  
  1612. .M3Unator-log-toggle svg {
  1613. width: 18px;
  1614. height: 18px;
  1615. color: #cba6f7;
  1616. opacity: 0.8;
  1617. transition: all 0.2s ease;
  1618. margin-right: 0.5rem;
  1619. }
  1620.  
  1621. .M3Unator-log-toggle.active svg {
  1622. transform: rotate(180deg);
  1623. opacity: 1;
  1624. }
  1625.  
  1626. .M3Unator-log-counter {
  1627. background: rgba(203, 166, 247, 0.1);
  1628. color: #cba6f7;
  1629. padding: 0.25rem 0.75rem;
  1630. border-radius: 12px;
  1631. font-size: 0.75rem;
  1632. font-weight: 600;
  1633. min-width: 1.5rem;
  1634. text-align: center;
  1635. display: inline-flex;
  1636. align-items: center;
  1637. justify-content: center;
  1638. margin-left: auto;
  1639. }
  1640.  
  1641. .M3Unator-log-toggle:hover .M3Unator-log-counter {
  1642. background: rgba(203, 166, 247, 0.15);
  1643. }
  1644.  
  1645. .M3Unator-log-toggle .toggle-text {
  1646. display: flex;
  1647. align-items: center;
  1648. gap: 0.5rem;
  1649. }
  1650.  
  1651. .M3Unator-log {
  1652. height: 0;
  1653. max-height: 0;
  1654. overflow: hidden;
  1655. transition: all 0.3s ease;
  1656. background: #11111b;
  1657. padding: 0;
  1658. border-top: none;
  1659. margin: 0;
  1660. }
  1661.  
  1662. .M3Unator-log.expanded {
  1663. height: auto;
  1664. max-height: 300px;
  1665. padding: 0.75rem;
  1666. border-top: 1px solid #313244;
  1667. overflow-y: auto;
  1668. }
  1669.  
  1670. .M3Unator-log-entry {
  1671. padding: 0.25rem 0.5rem;
  1672. border-bottom: 1px solid rgba(49, 50, 68, 0.5);
  1673. font-size: 0.875rem;
  1674. }
  1675.  
  1676. .M3Unator-log-entry:last-child {
  1677. border-bottom: none;
  1678. }
  1679.  
  1680. .M3Unator-log-time {
  1681. color: #6c7086;
  1682. margin-right: 0.5rem;
  1683. }
  1684.  
  1685. .M3Unator-log-entry.success {
  1686. color: #94e2d5;
  1687. }
  1688.  
  1689. .M3Unator-log-entry.error {
  1690. color: #f38ba8;
  1691. }
  1692.  
  1693. .M3Unator-log-entry.warning {
  1694. color: #fab387;
  1695. }
  1696.  
  1697. .M3Unator-log-entry.info {
  1698. color: #89b4fa;
  1699. }
  1700.  
  1701. .M3Unator-log-entry.final {
  1702. color: #a6e3a1;
  1703. font-weight: 500;
  1704. }
  1705.  
  1706. .M3Unator-log {
  1707. margin-top: 0.75rem;
  1708. max-height: calc(100vh - 70vh);
  1709. font-size: 0.8125rem;
  1710. line-height: 1.4;
  1711. }
  1712.  
  1713. .M3Unator-log-entry {
  1714. padding: 0.25rem 0.5rem;
  1715. border-radius: 4px;
  1716. }
  1717.  
  1718. .M3Unator-log-toggle {
  1719. padding: 0.5rem 0.75rem;
  1720. height: 36px;
  1721. }
  1722.  
  1723. .M3Unator-log-counter {
  1724. padding: 0.125rem 0.375rem;
  1725. font-size: 0.75rem;
  1726. border-radius: 4px;
  1727. }
  1728.  
  1729. .M3Unator-log-time {
  1730. font-size: 0.75rem;
  1731. opacity: 0.7;
  1732. margin-right: 0.5rem;
  1733. }
  1734. `);
  1735.  
  1736. GM_addStyle(`
  1737. .M3Unator-popup {
  1738. position: fixed;
  1739. background: #11111b;
  1740. color: #cdd6f4;
  1741. width: 100%;
  1742. max-width: 480px;
  1743. border-radius: 12px;
  1744. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  1745. overflow: hidden;
  1746. animation: slideUp 0.3s ease;
  1747. z-index: 9999;
  1748. }
  1749.  
  1750. .M3Unator-header {
  1751. padding: 1rem 1.25rem;
  1752. background: #1e1e2e;
  1753. color: #cdd6f4;
  1754. display: flex;
  1755. align-items: center;
  1756. justify-content: space-between;
  1757. cursor: move;
  1758. user-select: none;
  1759. border-bottom: 1px solid #313244;
  1760. }
  1761.  
  1762. .M3Unator-container {
  1763. position: fixed;
  1764. inset: 0;
  1765. background: rgba(0, 0, 0, 0.75);
  1766. backdrop-filter: blur(8px);
  1767. display: none;
  1768. place-items: center;
  1769. z-index: 9999;
  1770. }
  1771. `);
  1772.  
  1773. GM_addStyle(`
  1774. /* Info Modal Styles */
  1775. .info-modal {
  1776. display: none;
  1777. position: fixed;
  1778. inset: 0;
  1779. background: rgba(0, 0, 0, 0.75);
  1780. backdrop-filter: blur(8px);
  1781. z-index: 10000;
  1782. }
  1783.  
  1784. .info-modal-content {
  1785. position: absolute;
  1786. top: 50%;
  1787. left: 50%;
  1788. transform: translate(-50%, -50%);
  1789. background: #1e1e2e;
  1790. border: 1px solid #45475a;
  1791. border-radius: 12px;
  1792. width: 90%;
  1793. max-width: 600px;
  1794. color: #cdd6f4;
  1795. }
  1796.  
  1797. .info-modal-header {
  1798. padding: 1rem 1.5rem;
  1799. border-bottom: 1px solid #45475a;
  1800. display: flex;
  1801. align-items: center;
  1802. justify-content: space-between;
  1803. }
  1804.  
  1805. .info-modal-header h3 {
  1806. margin: 0;
  1807. color: #f5c2e7;
  1808. font-size: 1.25rem;
  1809. }
  1810.  
  1811. .info-modal-body {
  1812. padding: 1.5rem;
  1813. line-height: 1.6;
  1814. }
  1815.  
  1816. .info-modal-body p {
  1817. margin: 0 0 1rem;
  1818. }
  1819.  
  1820. .info-modal-body h4 {
  1821. margin: 1.5rem 0 0.75rem;
  1822. color: #f5c2e7;
  1823. }
  1824.  
  1825. .info-modal-body ul {
  1826. margin: 0.75rem 0;
  1827. padding-left: 1.5rem;
  1828. }
  1829.  
  1830. .info-modal-body li {
  1831. margin: 0.5rem 0;
  1832. }
  1833.  
  1834. .info-modal-body a {
  1835. color: #89b4fa;
  1836. text-decoration: none;
  1837. }
  1838.  
  1839. .info-modal-body a:hover {
  1840. text-decoration: underline;
  1841. }
  1842.  
  1843. .info-close {
  1844. cursor: pointer;
  1845. color: #6c7086;
  1846. transition: color 0.2s ease;
  1847. }
  1848.  
  1849. .info-close:hover {
  1850. color: #f5c2e7;
  1851. }
  1852. `);
  1853.  
  1854. GM_addStyle(`
  1855. .m3unator-input-group {
  1856. position: relative;
  1857. width: 100%;
  1858. }
  1859.  
  1860. .m3unator-input {
  1861. width: 100%;
  1862. padding-right: 80px !important;
  1863. transition: all 0.2s ease;
  1864. }
  1865.  
  1866. .m3unator-dropdown {
  1867. position: absolute;
  1868. right: 8px;
  1869. top: 50%;
  1870. transform: translateY(-50%);
  1871. display: none;
  1872. z-index: 1;
  1873. width: 70px;
  1874. }
  1875.  
  1876. .m3unator-dropdown.active {
  1877. display: block;
  1878. }
  1879.  
  1880. .m3unator-dropdown-button {
  1881. width: 100%;
  1882. padding: 4px 8px;
  1883. border-radius: 6px;
  1884. background: rgba(30, 30, 46, 0.6);
  1885. border: 1px solid rgba(69, 71, 90, 0.6);
  1886. color: #f5c2e7;
  1887. cursor: pointer;
  1888. display: flex;
  1889. align-items: center;
  1890. justify-content: space-between;
  1891. gap: 4px;
  1892. transition: all 0.2s ease;
  1893. }
  1894.  
  1895. .m3unator-dropdown-button:hover {
  1896. background: rgba(30, 30, 46, 0.8);
  1897. border-color: rgba(69, 71, 90, 0.8);
  1898. }
  1899.  
  1900. .m3unator-dropdown-menu {
  1901. position: absolute;
  1902. top: 100%;
  1903. right: 0;
  1904. width: 100%;
  1905. margin-top: 4px;
  1906. background: rgba(30, 30, 46, 0.95);
  1907. border: 1px solid rgba(69, 71, 90, 0.6);
  1908. border-radius: 6px;
  1909. padding: 4px;
  1910. display: none;
  1911. }
  1912.  
  1913. .m3unator-dropdown.active .m3unator-dropdown-menu {
  1914. display: block;
  1915. }
  1916.  
  1917. .m3unator-dropdown-item {
  1918. padding: 0.618rem;
  1919. color: #cdd6f4;
  1920. cursor: pointer;
  1921. transition: all 0.2s ease;
  1922. user-select: none;
  1923. }
  1924.  
  1925. .m3unator-dropdown-item:hover {
  1926. background: rgba(203, 166, 247, 0.1);
  1927. }
  1928.  
  1929. .m3unator-dropdown-item.selected {
  1930. background: rgba(203, 166, 247, 0.1);
  1931. color: #cba6f7;
  1932. }
  1933. `);
  1934.  
  1935. GM_addStyle(`
  1936. .M3Unator-container {
  1937. max-width: 400px;
  1938. width: 100%;
  1939. background: none;
  1940. backdrop-filter: none;
  1941. }
  1942.  
  1943. .M3Unator-popup {
  1944. background: #1e1e2e;
  1945. border-radius: 12px;
  1946. box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  1947. border: 1px solid rgba(69, 71, 90, 0.6);
  1948. }
  1949.  
  1950. .M3Unator-content {
  1951. padding: 0.75rem;
  1952. display: flex;
  1953. flex-direction: column;
  1954. gap: 0.75rem;
  1955. max-width: 100%;
  1956. overflow: hidden;
  1957. background: none;
  1958. }
  1959.  
  1960. .M3Unator-header {
  1961. padding: 0.75rem;
  1962. display: flex;
  1963. align-items: center;
  1964. justify-content: space-between;
  1965. background: none;
  1966. border-bottom: 1px solid rgba(69, 71, 90, 0.6);
  1967. }
  1968.  
  1969. .M3Unator-input {
  1970. width: 100%;
  1971. min-width: 0;
  1972. padding: 8px 80px 8px 12px;
  1973. box-sizing: border-box;
  1974. transition: all 0.2s ease;
  1975. background: #1e1e2e;
  1976. border: 1px solid rgba(69, 71, 90, 0.6);
  1977. border-radius: 6px;
  1978. color: #f5c2e7;
  1979. font-size: 14px;
  1980. }
  1981.  
  1982. .M3Unator-dropdown-button {
  1983. width: 100%;
  1984. padding: 4px 8px;
  1985. border-radius: 6px;
  1986. background: #1e1e2e;
  1987. border: 1px solid rgba(69, 71, 90, 0.6);
  1988. color: #f5c2e7;
  1989. cursor: pointer;
  1990. display: flex;
  1991. align-items: center;
  1992. justify-content: space-between;
  1993. gap: 4px;
  1994. transition: all 0.2s ease;
  1995. box-sizing: border-box;
  1996. font-size: 14px;
  1997. font-family: monospace;
  1998. }
  1999.  
  2000. .M3Unator-dropdown-button span {
  2001. min-width: 40px;
  2002. text-align: left;
  2003. }
  2004.  
  2005. .M3Unator-dropdown-button svg {
  2006. width: 16px;
  2007. height: 16px;
  2008. min-width: 16px;
  2009. min-height: 16px;
  2010. margin-left: auto;
  2011. }
  2012.  
  2013. .M3Unator-dropdown-menu {
  2014. position: absolute;
  2015. top: 100%;
  2016. right: 0;
  2017. width: 100%;
  2018. margin-top: 4px;
  2019. background: #1e1e2e;
  2020. border: 1px solid rgba(69, 71, 90, 0.6);
  2021. border-radius: 6px;
  2022. padding: 4px;
  2023. display: none;
  2024. box-sizing: border-box;
  2025. z-index: 9999;
  2026. }
  2027. `);
  2028.  
  2029. GM_addStyle(`
  2030. .M3Unator-content {
  2031. padding: 0.75rem;
  2032. display: flex;
  2033. flex-direction: column;
  2034. gap: 12px;
  2035. }
  2036.  
  2037. .M3Unator-toggle-group {
  2038. margin: 0;
  2039. display: flex;
  2040. gap: 0.75rem;
  2041. justify-content: center;
  2042. background: rgba(30, 30, 46, 0.4);
  2043. padding: 0.75rem;
  2044. border-radius: 12px;
  2045. }
  2046.  
  2047. .M3Unator-button {
  2048. margin: 0;
  2049. }
  2050.  
  2051. .M3Unator-log-container {
  2052. margin: 0;
  2053. }
  2054.  
  2055. .M3Unator-stats-bar {
  2056. margin: 0;
  2057. }
  2058. `);
  2059.  
  2060. GM_addStyle(`
  2061. /* Dropdown Styles */
  2062. .M3Unator-dropdown {
  2063. position: relative;
  2064. display: none;
  2065. }
  2066.  
  2067. .M3Unator-dropdown-button {
  2068. width: 100%;
  2069. padding: 4px 8px;
  2070. border-radius: 6px;
  2071. background: #1e1e2e;
  2072. border: 1px solid rgba(69, 71, 90, 0.6);
  2073. color: #f5c2e7;
  2074. cursor: pointer;
  2075. display: flex;
  2076. align-items: center;
  2077. justify-content: space-between;
  2078. gap: 4px;
  2079. transition: all 0.2s ease;
  2080. box-sizing: border-box;
  2081. font-size: 14px;
  2082. font-family: monospace;
  2083. }
  2084.  
  2085. .M3Unator-dropdown-button span {
  2086. min-width: 40px;
  2087. text-align: left;
  2088. }
  2089.  
  2090. .M3Unator-dropdown-button svg {
  2091. width: 16px;
  2092. height: 16px;
  2093. min-width: 16px;
  2094. min-height: 16px;
  2095. margin-left: auto;
  2096. transition: transform 0.2s ease;
  2097. }
  2098.  
  2099. .M3Unator-dropdown.active .M3Unator-dropdown-button svg {
  2100. transform: rotate(180deg);
  2101. }
  2102.  
  2103. .M3Unator-dropdown-menu {
  2104. position: absolute;
  2105. top: 100%;
  2106. left: 0;
  2107. right: 0;
  2108. margin-top: 4px;
  2109. background: #1e1e2e;
  2110. border: 1px solid rgba(69, 71, 90, 0.6);
  2111. border-radius: 6px;
  2112. overflow: hidden;
  2113. z-index: 1000;
  2114. display: none;
  2115. }
  2116.  
  2117. .M3Unator-dropdown.active .M3Unator-dropdown-menu {
  2118. display: block;
  2119. }
  2120.  
  2121. .M3Unator-dropdown-item {
  2122. padding: 6px 12px;
  2123. color: #f5c2e7;
  2124. cursor: pointer;
  2125. transition: all 0.2s ease;
  2126. font-family: monospace;
  2127. }
  2128.  
  2129. .M3Unator-dropdown-item:hover {
  2130. background: rgba(69, 71, 90, 0.3);
  2131. }
  2132.  
  2133. .M3Unator-dropdown-item:not(:last-child) {
  2134. border-bottom: 1px solid rgba(69, 71, 90, 0.3);
  2135. }
  2136.  
  2137. /* Input Styles */
  2138. .M3Unator-input {
  2139. width: 100%;
  2140. height: 42px;
  2141. padding: 0 12px;
  2142. border: 1px solid #45475a;
  2143. border-radius: 8px;
  2144. background: #1e1e2e;
  2145. color: #f5c2e7;
  2146. font-size: 14px;
  2147. transition: all 0.2s ease;
  2148. box-sizing: border-box;
  2149. }
  2150.  
  2151. .M3Unator-input:focus {
  2152. outline: none;
  2153. border-color: #f5c2e7;
  2154. box-shadow: 0 0 0 2px rgba(245, 194, 231, 0.1);
  2155. }
  2156.  
  2157. /* Button Styles */
  2158. .M3Unator-button {
  2159. height: 42px;
  2160. padding: 0 16px;
  2161. border: none;
  2162. border-radius: 8px;
  2163. background: #f5c2e7;
  2164. color: #1e1e2e;
  2165. font-weight: 600;
  2166. font-size: 14px;
  2167. cursor: pointer;
  2168. transition: all 0.2s ease;
  2169. display: flex;
  2170. align-items: center;
  2171. justify-content: center;
  2172. gap: 8px;
  2173. }
  2174.  
  2175. /* Toggle Container Styles */
  2176. .M3Unator-toggle-container {
  2177. position: relative;
  2178. display: flex;
  2179. align-items: center;
  2180. gap: 0.5rem;
  2181. transition: all 0.2s ease;
  2182. }
  2183.  
  2184. /* Control Button Styles */
  2185. .M3Unator-control-btn {
  2186. padding: 0.75rem 1.5rem;
  2187. border-radius: 12px;
  2188. font-weight: 600;
  2189. font-size: 0.95rem;
  2190. min-width: 160px;
  2191. background: rgba(30, 30, 46, 0.6);
  2192. backdrop-filter: blur(8px);
  2193. }
  2194.  
  2195. .M3Unator-control-btn.pause {
  2196. border-color: #fab387;
  2197. color: #fab387;
  2198. }
  2199.  
  2200. .M3Unator-control-btn.resume {
  2201. border-color: #94e2d5;
  2202. color: #94e2d5;
  2203. }
  2204.  
  2205. .M3Unator-control-btn.cancel {
  2206. border-color: #f38ba8;
  2207. color: #f38ba8;
  2208. }
  2209.  
  2210. /* Stats Styles */
  2211. .M3Unator-stat {
  2212. display: inline-flex;
  2213. align-items: center;
  2214. gap: 0.382rem;
  2215. font-size: 0.875rem;
  2216. cursor: help;
  2217. min-width: 52px;
  2218. padding: 0 0.382rem;
  2219. }
  2220. `);
  2221.  
  2222. class PlaylistGenerator {
  2223. constructor() {
  2224. this.initialStats = {
  2225. directories: {
  2226. total: 0,
  2227. depth: 0
  2228. },
  2229. files: {
  2230. video: {
  2231. total: 0,
  2232. current: 0
  2233. },
  2234. audio: {
  2235. total: 0,
  2236. current: 0
  2237. }
  2238. },
  2239. errors: {
  2240. total: 0,
  2241. skipped: 0
  2242. },
  2243. totalFiles: 0
  2244. };
  2245.  
  2246. this.domElements = {};
  2247.  
  2248. this.state = {
  2249. isGenerating: false,
  2250. isPaused: false,
  2251. selectedFormat: 'm3u',
  2252. includeVideo: false,
  2253. includeAudio: false,
  2254. maxEntries: 100000,
  2255. timeoutMs: 5000,
  2256. retryCount: 2,
  2257. maxDepth: 0,
  2258. maxSeenUrls: 5000,
  2259. stats: { ...this.initialStats }
  2260. };
  2261.  
  2262. this.sortOptions = { numeric: true, sensitivity: 'base' };
  2263.  
  2264. this.entries = [];
  2265. this.seenUrls = new Set();
  2266. this.toastQueue = [];
  2267. this.isProcessingToast = false;
  2268.  
  2269. this.videoFormats = [
  2270. '.mp4', '.mkv', '.avi', '.webm', '.mov', '.flv', '.wmv',
  2271. '.m4v', '.mpg', '.mpeg', '.3gp', '.vob', '.ts', '.mts',
  2272. '.m2ts', '.divx', '.xvid', '.asf', '.ogv', '.rm', '.rmvb',
  2273. '.wtv', '.qt', '.hevc', '.f4v', '.swf', '.vro', '.ogx',
  2274. '.drc', '.gifv', '.mxf', '.roq', '.nsv'
  2275. ];
  2276.  
  2277. this.audioFormats = [
  2278. '.mp3', '.m4a', '.wav', '.flac', '.aac', '.ogg', '.wma',
  2279. '.opus', '.aiff', '.ape', '.mka', '.ac3', '.dts', '.m4b',
  2280. '.m4p', '.m4r', '.mid', '.midi', '.mp2', '.mpa', '.mpc',
  2281. '.ra', '.tta', '.voc', '.vox', '.amr', '.awb', '.dsf',
  2282. '.dff', '.alac', '.wv', '.oga', '.sln', '.aif', '.pcm'
  2283. ];
  2284.  
  2285. this.icons = {
  2286. video: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2287. <polygon points="23 7 16 12 23 17 23 7"/>
  2288. <rect x="1" y="5" width="15" height="14" rx="2" ry="2"/>
  2289. </svg>`,
  2290. audio: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2291. <path d="M9 18V5l12-2v13"/>
  2292. <circle cx="6" cy="18" r="3"/>
  2293. <circle cx="18" cy="16" r="3"/>
  2294. </svg>`,
  2295. folder: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2296. <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
  2297. </svg>`,
  2298. info: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2299. <circle cx="12" cy="12" r="10"/>
  2300. <line x1="12" y1="16" x2="12" y2="12"/>
  2301. <line x1="12" y1="8" x2="12.01" y2="8"/>
  2302. </svg>`,
  2303. file: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2304. <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
  2305. <polyline points="13 2 13 9 20 9"/>
  2306. </svg>`,
  2307. download: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2308. <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
  2309. <polyline points="7 10 12 15 17 10"/>
  2310. <line x1="12" y1="15" x2="12" y2="3"/>
  2311. </svg>`,
  2312. close: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2313. <line x1="18" y1="6" x2="6" y2="18"/>
  2314. <line x1="6" y1="6" x2="18" y2="18"/>
  2315. </svg>`,
  2316. pause: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2317. <rect x="6" y="4" width="4" height="16"/>
  2318. <rect x="14" y="4" width="4" height="16"/>
  2319. </svg>`,
  2320. resume: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2321. <polygon points="5 3 19 12 5 21 5 3"/>
  2322. </svg>`,
  2323. cancel: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2324. <circle cx="12" cy="12" r="10"/>
  2325. <line x1="15" y1="9" x2="9" y2="15"/>
  2326. <line x1="9" y1="9" x2="15" y2="15"/>
  2327. </svg>`,
  2328. success: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2329. <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
  2330. <polyline points="22 4 12 14.01 9 11.01"/>
  2331. </svg>`,
  2332. error: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2333. <circle cx="12" cy="12" r="10"/>
  2334. <line x1="12" y1="8" x2="12" y2="12"/>
  2335. <line x1="12" y1="16" x2="12.01" y2="16"/>
  2336. </svg>`,
  2337. warning: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2338. <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
  2339. <line x1="12" y1="9" x2="12" y2="13"/>
  2340. <line x1="12" y1="17" x2="12.01" y2="17"/>
  2341. </svg>`,
  2342. github: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
  2343. <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
  2344. </svg>`,
  2345. twitter: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
  2346. <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>
  2347. </svg>`,
  2348. chevronDown: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2349. <polyline points="6 9 12 15 18 9"/>
  2350. </svg>`,
  2351. layers: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2352. <polygon points="12 2 2 7 12 12 22 7 12 2"/>
  2353. <polyline points="2 17 12 22 22 17"/>
  2354. <polyline points="2 12 12 17 22 12"/>
  2355. </svg>`,
  2356. logToggle: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  2357. <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
  2358. </svg>`
  2359. };
  2360.  
  2361. this.templates = {
  2362. toggleButton: (id, title, icon, checked = false) => `
  2363. <div class="M3Unator-toggle-container">
  2364. <label>
  2365. <input type="checkbox" id="${id}" ${checked ? 'checked' : ''}>
  2366. <span title="${title}">${icon}</span>
  2367. </label>
  2368. </div>
  2369. `,
  2370. controlButton: (type, icon, text) => `
  2371. <button class="M3Unator-control-btn ${type}">
  2372. ${icon}
  2373. <span>${text}</span>
  2374. </button>
  2375. `,
  2376. statsItem: (icon, id, title, className = '') => `
  2377. <span class="M3Unator-stat ${className}" title="${title}">
  2378. ${icon}
  2379. <span id="${id}">0</span>
  2380. </span>
  2381. `
  2382. };
  2383.  
  2384. this.baseStyles = `
  2385. .M3Unator-btn-base {
  2386. border: none;
  2387. border-radius: 8px;
  2388. font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  2389. font-weight: 600;
  2390. cursor: pointer;
  2391. transition: all 0.2s ease;
  2392. display: flex;
  2393. align-items: center;
  2394. justify-content: center;
  2395. gap: 0.5rem;
  2396. }
  2397.  
  2398. .M3Unator-toggle-base {
  2399. position: relative;
  2400. display: flex;
  2401. align-items: center;
  2402. gap: 0.5rem;
  2403. transition: all 0.2s ease;
  2404. }
  2405.  
  2406. .M3Unator-control-base {
  2407. padding: 0.75rem 1.5rem;
  2408. border-radius: 12px;
  2409. font-weight: 600;
  2410. font-size: 0.95rem;
  2411. min-width: 160px;
  2412. background: rgba(30, 30, 46, 0.6);
  2413. backdrop-filter: blur(8px);
  2414. }
  2415.  
  2416. .M3Unator-stat-base {
  2417. display: inline-flex;
  2418. align-items: center;
  2419. gap: 0.382rem;
  2420. font-size: 0.875rem;
  2421. cursor: help;
  2422. min-width: 52px;
  2423. padding: 0 0.382rem;
  2424. }
  2425.  
  2426. .M3Unator-icon-base {
  2427. display: flex;
  2428. align-items: center;
  2429. justify-content: center;
  2430. width: 24px;
  2431. height: 24px;
  2432. transition: all 0.2s ease;
  2433. }
  2434. `;
  2435.  
  2436. GM_addStyle(this.baseStyles);
  2437. }
  2438.  
  2439. createComponent(type, props) {
  2440. switch (type) {
  2441. case 'toggle':
  2442. return this.templates.toggleButton(
  2443. props.id,
  2444. props.title,
  2445. props.icon,
  2446. props.checked
  2447. );
  2448. case 'control':
  2449. return this.templates.controlButton(
  2450. props.type,
  2451. props.icon,
  2452. props.text
  2453. );
  2454. case 'stats':
  2455. return `
  2456. <span class="M3Unator-stat ${props.class}" title="${props.title}">
  2457. ${props.icon}
  2458. <span id="${props.id}">0</span>
  2459. </span>
  2460. `;
  2461. default:
  2462. return '';
  2463. }
  2464. }
  2465.  
  2466. async init() {
  2467. const container = document.createElement('div');
  2468. container.className = 'M3Unator-container';
  2469.  
  2470. const toggleButtons = [
  2471. {
  2472. id: 'includeVideo',
  2473. title: 'Video (.mp4, .mkv)',
  2474. icon: this.icons.video,
  2475. checked: true
  2476. },
  2477. {
  2478. id: 'includeAudio',
  2479. title: 'Audio (.mp3, .m4a)',
  2480. icon: this.icons.audio,
  2481. checked: true
  2482. },
  2483. {
  2484. id: 'recursiveSearch',
  2485. title: 'Scan Subdirectories',
  2486. icon: this.icons.folder,
  2487. checked: true
  2488. }
  2489. ].map(props => this.createComponent('toggle', props)).join('');
  2490.  
  2491. const controlButtons = [
  2492. {
  2493. type: 'pause',
  2494. icon: this.icons.pause,
  2495. text: 'Pause'
  2496. },
  2497. {
  2498. type: 'resume',
  2499. icon: this.icons.resume,
  2500. text: 'Resume'
  2501. },
  2502. {
  2503. type: 'cancel',
  2504. icon: this.icons.cancel,
  2505. text: 'Cancel'
  2506. }
  2507. ].map(props => this.createComponent('control', props)).join('');
  2508.  
  2509. const statsItems = [
  2510. {
  2511. icon: this.icons.file,
  2512. id: 'totalFiles',
  2513. title: 'Total Files',
  2514. class: ''
  2515. },
  2516. {
  2517. icon: this.icons.video,
  2518. id: 'videoFiles',
  2519. title: 'Video (.mp4, .mkv)',
  2520. class: 'video'
  2521. },
  2522. {
  2523. icon: this.icons.audio,
  2524. id: 'audioFiles',
  2525. title: 'Audio (.mp3, .m4a)',
  2526. class: 'audio'
  2527. },
  2528. {
  2529. icon: this.icons.folder,
  2530. id: 'directories',
  2531. title: 'Subdirectories',
  2532. class: 'dir'
  2533. },
  2534. {
  2535. icon: this.icons.layers,
  2536. id: 'depthLevel',
  2537. title: 'Depth Level',
  2538. class: 'depth'
  2539. },
  2540. {
  2541. icon: this.icons.error,
  2542. id: 'errors',
  2543. title: 'Error',
  2544. class: 'error'
  2545. }
  2546. ].map(props => this.createComponent('stats', props)).join('');
  2547.  
  2548. container.innerHTML = `
  2549. <div class="M3Unator-popup">
  2550. <div class="M3Unator-header">
  2551. <h3 class="M3Unator-title">
  2552. ${this.icons.video}
  2553. <span>M3Unator</span>
  2554. </h3>
  2555. <div style="display: flex; align-items: center;">
  2556. <div class="M3Unator-social">
  2557. <a class="info-link">
  2558. ${this.icons.info}
  2559. </a>
  2560. <a href="https://github.com/hasanbeder/M3Unator" target="_blank" rel="noopener noreferrer" class="github-icon">
  2561. ${this.icons.github}
  2562. </a>
  2563. <a href="https://x.com/hasanbeder" target="_blank" rel="noopener noreferrer">
  2564. ${this.icons.twitter}
  2565. </a>
  2566. </div>
  2567. <button class="M3Unator-close">${this.icons.close}</button>
  2568. </div>
  2569. </div>
  2570. <div class="info-modal">
  2571. <div class="info-modal-content">
  2572. <div class="info-modal-header">
  2573. <h3>About M3Unator</h3>
  2574. <span class="info-close">${this.icons.close}</span>
  2575. </div>
  2576. <div class="info-modal-body">
  2577. <p><strong>M3Unator v1.0.1</strong> - Web Directory Playlist Creator</p>
  2578. <p>Create M3U/M3U8 playlists from directory listing pages. Automatically finds video and audio files in web server indexes.</p>
  2579. <h4>Features:</h4>
  2580. <ul>
  2581. <li>Supports video formats: MP4, MKV, AVI, etc.</li>
  2582. <li>Supports audio formats: MP3, M4A, FLAC, etc.</li>
  2583. <li>Recursive directory scanning</li>
  2584. <li>Custom playlist naming</li>
  2585. <li>Progress tracking</li>
  2586. <li>Dark theme interface</li>
  2587. </ul>
  2588. <p>For more information and updates, visit the <a href="https://github.com/hasanbeder/M3Unator" target="_blank">GitHub repository</a>.</p>
  2589. </div>
  2590. </div>
  2591. </div>
  2592. <div class="M3Unator-content">
  2593. <div class="M3Unator-input-row">
  2594. <div class="M3Unator-input-group">
  2595. <input type="text"
  2596. id="playlistName"
  2597. class="M3Unator-input"
  2598. placeholder="Playlist Name"
  2599. required
  2600. spellcheck="false"
  2601. autocomplete="off"
  2602. autocorrect="off"
  2603. autocapitalize="off">
  2604.  
  2605. <div class="M3Unator-dropdown">
  2606. <button type="button" class="M3Unator-dropdown-button">
  2607. <span>.m3u</span>
  2608. ${this.icons.chevronDown}
  2609. </button>
  2610. <div class="M3Unator-dropdown-menu">
  2611. <div class="M3Unator-dropdown-item selected" data-value="m3u">.m3u</div>
  2612. <div class="M3Unator-dropdown-divider"></div>
  2613. <div class="M3Unator-dropdown-item" data-value="m3u8">.m3u8</div>
  2614. </div>
  2615. </div>
  2616. </div>
  2617. </div>
  2618.  
  2619. <div class="M3Unator-toggle-group">
  2620. ${toggleButtons}
  2621. </div>
  2622.  
  2623. <div class="M3Unator-depth-controls">
  2624. <div class="M3Unator-radio-group">
  2625. <label class="M3Unator-radio">
  2626. <input type="radio" name="depthType" value="current" id="currentDepth">
  2627. <span class="radio-mark"></span>
  2628. <span class="radio-label">Current directory</span>
  2629. </label>
  2630. <label class="M3Unator-radio">
  2631. <input type="radio" name="depthType" value="custom" id="customDepth">
  2632. <span class="radio-mark"></span>
  2633. <span class="radio-label">Custom depth:</span>
  2634. <input type="number"
  2635. id="maxDepth"
  2636. value="1"
  2637. min="1"
  2638. max="99"
  2639. class="M3Unator-depth-input"
  2640. title="Subdirectory scan depth"
  2641. style="width: 64px;"
  2642. inputmode="numeric"
  2643. pattern="[0-9]*">
  2644. </label>
  2645. </div>
  2646. </div>
  2647.  
  2648. <button class="M3Unator-button" id="generateBtn">
  2649. ${this.icons.download}
  2650. <span>Create Playlist</span>
  2651. </button>
  2652.  
  2653. <div class="M3Unator-controls">
  2654. ${controlButtons}
  2655. </div>
  2656.  
  2657. <div class="M3Unator-stats-bar">
  2658. <div class="M3Unator-stats">
  2659. ${statsItems}
  2660. </div>
  2661. </div>
  2662.  
  2663. <div class="M3Unator-log-container">
  2664. <button class="M3Unator-log-toggle">
  2665. <div class="toggle-text">
  2666. ${this.icons.logToggle}
  2667. <span>Log Messages</span>
  2668. </div>
  2669. <span class="M3Unator-log-counter">0</span>
  2670. </button>
  2671. <div id="scanLog" class="M3Unator-log collapsed"></div>
  2672. </div>
  2673. </div>
  2674.  
  2675. <style>
  2676. .M3Unator-container {
  2677. max-width: 400px;
  2678. width: 100%;
  2679. background: transparent;
  2680. backdrop-filter: none;
  2681. }
  2682.  
  2683. .M3Unator-popup {
  2684. background: #1e1e2e;
  2685. border-radius: 12px;
  2686. box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  2687. border: 1px solid rgba(69, 71, 90, 0.6);
  2688. }
  2689.  
  2690. .info-modal {
  2691. display: none;
  2692. position: fixed;
  2693. top: 0;
  2694. left: 0;
  2695. width: 100%;
  2696. height: 100%;
  2697. background: rgba(0, 0, 0, 0.75);
  2698. z-index: 99999;
  2699. }
  2700.  
  2701. .info-content {
  2702. position: absolute;
  2703. top: 50%;
  2704. left: 50%;
  2705. transform: translate(-50%, -50%);
  2706. background: #1e1e2e;
  2707. padding: 2rem;
  2708. border-radius: 12px;
  2709. max-width: 600px;
  2710. width: 90%;
  2711. max-height: 80vh;
  2712. overflow-y: auto;
  2713. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  2714. border: 1px solid rgba(69, 71, 90, 0.6);
  2715. }
  2716.  
  2717. .M3Unator-content {
  2718. padding: 0.75rem;
  2719. display: flex;
  2720. flex-direction: column;
  2721. gap: 0.75rem;
  2722. max-width: 100%;
  2723. overflow: hidden;
  2724. }
  2725.  
  2726. .M3Unator-input-row {
  2727. display: flex;
  2728. width: 100%;
  2729. position: relative;
  2730. max-width: 100%;
  2731. overflow: visible;
  2732. }
  2733.  
  2734. .M3Unator-input-group {
  2735. flex: 1;
  2736. min-width: 0;
  2737. position: relative;
  2738. }
  2739.  
  2740. .M3Unator-input {
  2741. width: 100%;
  2742. min-width: 0;
  2743. padding-right: 80px;
  2744. box-sizing: border-box;
  2745. transition: all 0.2s ease;
  2746. background: rgba(30, 30, 46, 0.6);
  2747. border: 1px solid rgba(69, 71, 90, 0.6);
  2748. border-radius: 6px;
  2749. color: #f5c2e7;
  2750. padding: 8px 80px 8px 12px;
  2751. font-size: 14px;
  2752. }
  2753.  
  2754. .M3Unator-dropdown {
  2755. position: absolute;
  2756. right: 8px;
  2757. top: 50%;
  2758. transform: translateY(-50%);
  2759. width: 70px;
  2760. z-index: 9999;
  2761. display: none;
  2762. }
  2763.  
  2764. .M3Unator-dropdown.active {
  2765. display: block;
  2766. }
  2767.  
  2768. .M3Unator-dropdown-button {
  2769. width: 100%;
  2770. padding: 4px 8px;
  2771. border-radius: 6px;
  2772. background: rgba(30, 30, 46, 0.8);
  2773. border: 1px solid rgba(69, 71, 90, 0.6);
  2774. color: #f5c2e7;
  2775. cursor: pointer;
  2776. display: flex;
  2777. align-items: center;
  2778. justify-content: space-between;
  2779. gap: 4px;
  2780. transition: all 0.2s ease;
  2781. box-sizing: border-box;
  2782. font-size: 14px;
  2783. }
  2784.  
  2785. .M3Unator-dropdown-button:hover {
  2786. background: rgba(30, 30, 46, 0.9);
  2787. border-color: rgba(69, 71, 90, 0.8);
  2788. }
  2789.  
  2790. .M3Unator-dropdown-menu {
  2791. position: absolute;
  2792. top: 100%;
  2793. right: 0;
  2794. width: 100%;
  2795. margin-top: 4px;
  2796. background: rgba(30, 30, 46, 0.95);
  2797. border: 1px solid rgba(69, 71, 90, 0.6);
  2798. border-radius: 6px;
  2799. padding: 4px;
  2800. display: none;
  2801. box-sizing: border-box;
  2802. z-index: 9999;
  2803. }
  2804.  
  2805. .M3Unator-dropdown.active .M3Unator-dropdown-menu {
  2806. display: block;
  2807. }
  2808.  
  2809. .M3Unator-dropdown-item {
  2810. padding: 8px 12px;
  2811. cursor: pointer;
  2812. border-radius: 4px;
  2813. transition: all 0.2s ease;
  2814. text-align: center;
  2815. font-size: 14px;
  2816. font-family: monospace;
  2817. color: #cdd6f4;
  2818. }
  2819.  
  2820. .M3Unator-dropdown-divider {
  2821. height: 1px;
  2822. background: rgba(69, 71, 90, 0.6);
  2823. margin: 6px 0;
  2824. }
  2825.  
  2826. .M3Unator-dropdown-menu {
  2827. position: absolute;
  2828. top: 100%;
  2829. right: 0;
  2830. width: 100%;
  2831. margin-top: 4px;
  2832. background: #1e1e2e;
  2833. border: 1px solid rgba(69, 71, 90, 0.6);
  2834. border-radius: 6px;
  2835. padding: 6px;
  2836. display: none;
  2837. box-sizing: border-box;
  2838. z-index: 9999;
  2839. }
  2840.  
  2841. .M3Unator-dropdown-button {
  2842. width: 100%;
  2843. padding: 4px 8px;
  2844. border-radius: 6px;
  2845. background: #1e1e2e;
  2846. border: 1px solid rgba(69, 71, 90, 0.6);
  2847. color: #f5c2e7;
  2848. cursor: pointer;
  2849. display: flex;
  2850. align-items: center;
  2851. justify-content: space-between;
  2852. gap: 4px;
  2853. transition: all 0.2s ease;
  2854. box-sizing: border-box;
  2855. font-size: 14px;
  2856. font-family: monospace;
  2857. }
  2858.  
  2859. .M3Unator-dropdown-item:hover {
  2860. background: rgba(203, 166, 247, 0.1);
  2861. color: #f5c2e7;
  2862. }
  2863.  
  2864. .M3Unator-dropdown-item.selected {
  2865. background: rgba(203, 166, 247, 0.1);
  2866. color: #cba6f7;
  2867. }
  2868. </style>
  2869. </div>
  2870. `;
  2871.  
  2872. document.body.appendChild(container);
  2873. const launcher = document.createElement('button');
  2874. launcher.className = 'M3Unator-launcher';
  2875. launcher.innerHTML = `
  2876. ${this.icons.video}
  2877. <span>M3Unator</span>
  2878. `;
  2879. document.body.appendChild(launcher);
  2880. const popup = container.querySelector('.M3Unator-popup');
  2881. const header = container.querySelector('.M3Unator-header');
  2882. this.makeDraggable(popup, header);
  2883. const statsBar = container.querySelector('.M3Unator-stats-bar');
  2884. if (statsBar) {
  2885. statsBar.style.display = 'block';
  2886. }
  2887.  
  2888. this.domElements = {
  2889. container,
  2890. popup: container.querySelector('.M3Unator-popup'),
  2891. header: container.querySelector('.M3Unator-header'),
  2892. closeBtn: container.querySelector('.M3Unator-close'),
  2893. generateBtn: container.querySelector('#generateBtn'),
  2894. playlistInput: container.querySelector('#playlistName'),
  2895. includeVideo: container.querySelector('#includeVideo'),
  2896. includeAudio: container.querySelector('#includeAudio'),
  2897. recursiveSearch: container.querySelector('#recursiveSearch'),
  2898. controls: container.querySelector('.M3Unator-controls'),
  2899. scanLog: container.querySelector('#scanLog'),
  2900. statsBar: container.querySelector('.M3Unator-stats-bar'),
  2901. dropdown: container.querySelector('.M3Unator-dropdown'),
  2902. launcher,
  2903. stats: {
  2904. totalFiles: container.querySelector('#totalFiles'),
  2905. videoFiles: container.querySelector('#videoFiles'),
  2906. audioFiles: container.querySelector('#audioFiles'),
  2907. directories: container.querySelector('#directories'),
  2908. depthLevel: container.querySelector('#depthLevel'),
  2909. errors: container.querySelector('#errors')
  2910. },
  2911. depthControls: container.querySelector('.M3Unator-depth-controls'),
  2912. currentDepth: container.querySelector('#currentDepth'),
  2913. customDepth: container.querySelector('#customDepth'),
  2914. maxDepth: container.querySelector('#maxDepth'),
  2915. logToggle: container.querySelector('.M3Unator-log-toggle'),
  2916. logCounter: container.querySelector('.M3Unator-log-counter'),
  2917. };
  2918.  
  2919. launcher.onclick = () => {
  2920. this.domElements.container.setAttribute('data-visible', 'true');
  2921. const overlay = document.createElement('div');
  2922. overlay.className = 'M3Unator-overlay';
  2923. document.body.appendChild(overlay);
  2924. const popup = this.domElements.popup;
  2925. const rect = popup.getBoundingClientRect();
  2926. const centerX = (window.innerWidth - rect.width) / 2;
  2927. const centerY = (window.innerHeight - rect.height) / 2;
  2928. popup.style.left = `${centerX}px`;
  2929. popup.style.top = `${centerY}px`;
  2930. };
  2931.  
  2932. document.querySelector('.M3Unator-close').onclick = () => {
  2933. if (this.state.isGenerating) {
  2934. this.state.isGenerating = false;
  2935. this.state.isPaused = false;
  2936. this.reset({ isCancelled: true, enableToggles: true });
  2937. this.showToast('Scan cancelled', 'warning');
  2938. }
  2939. this.domElements.container.removeAttribute('data-visible');
  2940. const overlay = document.querySelector('.M3Unator-overlay');
  2941. if (overlay) overlay.remove();
  2942. };
  2943.  
  2944. this.setupPopupHandlers();
  2945.  
  2946. this.updateCounter(0);
  2947.  
  2948. this.domElements.logToggle.addEventListener('click', () => {
  2949. const log = this.domElements.scanLog;
  2950. const toggle = this.domElements.logToggle;
  2951. if (log.classList.contains('expanded')) {
  2952. log.classList.remove('expanded');
  2953. toggle.classList.remove('active');
  2954. } else {
  2955. log.classList.add('expanded');
  2956. toggle.classList.add('active');
  2957. log.scrollTop = log.scrollHeight;
  2958. }
  2959. });
  2960.  
  2961. this.domElements.scanLog.classList.remove('expanded');
  2962. this.domElements.logToggle.classList.remove('active');
  2963.  
  2964. this.logCount = 0;
  2965. }
  2966.  
  2967. updateStyles() {
  2968. GM_addStyle(`
  2969. .M3Unator-toggle-container {
  2970. @extend .M3Unator-toggle-base;
  2971. }
  2972.  
  2973. .M3Unator-control-btn {
  2974. @extend .M3Unator-control-base;
  2975. }
  2976.  
  2977. .M3Unator-stat {
  2978. @extend .M3Unator-stat-base;
  2979. }
  2980.  
  2981. .M3Unator-toggle-container span {
  2982. @extend .M3Unator-icon-base;
  2983. background: #1e1e2e;
  2984. border: 2px solid #45475a;
  2985. border-radius: 16px;
  2986. }
  2987.  
  2988. .M3Unator-control-btn.pause {
  2989. border-color: #fab387;
  2990. color: #fab387;
  2991. }
  2992.  
  2993. .M3Unator-control-btn.resume {
  2994. border-color: #94e2d5;
  2995. color: #94e2d5;
  2996. }
  2997.  
  2998. .M3Unator-control-btn.cancel {
  2999. border-color: #f38ba8;
  3000. color: #f38ba8;
  3001. }
  3002.  
  3003. `);
  3004. }
  3005.  
  3006. makeDraggable(element, handle) {
  3007. let isDragging = false;
  3008. let currentX;
  3009. let currentY;
  3010. let initialX;
  3011. let initialY;
  3012. let xOffset = 0;
  3013. let yOffset = 0;
  3014.  
  3015. const centerWindow = () => {
  3016. const rect = element.getBoundingClientRect();
  3017. const centerX = (window.innerWidth - rect.width) / 2;
  3018. const centerY = (window.innerHeight - rect.height) / 2;
  3019. element.style.left = `${centerX}px`;
  3020. element.style.top = `${centerY}px`;
  3021. xOffset = centerX;
  3022. yOffset = centerY;
  3023. element.style.transform = 'none';
  3024. };
  3025.  
  3026. centerWindow();
  3027.  
  3028. const getPosition = (e) => {
  3029. return {
  3030. x: e.type.includes('touch') ? e.touches[0].clientX : e.clientX,
  3031. y: e.type.includes('touch') ? e.touches[0].clientY : e.clientY
  3032. };
  3033. };
  3034.  
  3035. const dragStart = (e) => {
  3036. if (e.target === handle || handle.contains(e.target)) {
  3037. e.preventDefault();
  3038. const pos = getPosition(e);
  3039. isDragging = true;
  3040. const rect = element.getBoundingClientRect();
  3041. xOffset = rect.left;
  3042. yOffset = rect.top;
  3043. initialX = pos.x - xOffset;
  3044. initialY = pos.y - yOffset;
  3045.  
  3046. handle.style.cursor = 'grabbing';
  3047. }
  3048. };
  3049.  
  3050. const drag = (e) => {
  3051. if (isDragging) {
  3052. e.preventDefault();
  3053. const pos = getPosition(e);
  3054.  
  3055. currentX = pos.x - initialX;
  3056. currentY = pos.y - initialY;
  3057.  
  3058. const rect = element.getBoundingClientRect();
  3059. const maxX = window.innerWidth - rect.width;
  3060. const maxY = window.innerHeight - rect.height;
  3061.  
  3062. currentX = Math.min(Math.max(0, currentX), maxX);
  3063. currentY = Math.min(Math.max(0, currentY), maxY);
  3064.  
  3065. element.style.left = `${currentX}px`;
  3066. element.style.top = `${currentY}px`;
  3067. xOffset = currentX;
  3068. yOffset = currentY;
  3069. }
  3070. };
  3071.  
  3072. const dragEnd = () => {
  3073. if (isDragging) {
  3074. isDragging = false;
  3075. handle.style.cursor = 'grab';
  3076. }
  3077. };
  3078.  
  3079. handle.addEventListener('mousedown', dragStart);
  3080. document.addEventListener('mousemove', drag);
  3081. document.addEventListener('mouseup', dragEnd);
  3082.  
  3083. handle.addEventListener('touchstart', dragStart, { passive: false });
  3084. document.addEventListener('touchmove', drag, { passive: false });
  3085. document.addEventListener('touchend', dragEnd);
  3086.  
  3087. window.addEventListener('resize', () => {
  3088. if (!isDragging) {
  3089. centerWindow();
  3090. }
  3091. });
  3092.  
  3093. handle.style.cursor = 'grab';
  3094. handle.style.userSelect = 'none';
  3095. handle.style.touchAction = 'none';
  3096.  
  3097. element.style.position = 'fixed';
  3098. element.style.margin = '0';
  3099. element.style.touchAction = 'none';
  3100. element.style.transition = 'none';
  3101. }
  3102.  
  3103. showToast(message, type = 'success', duration = 3000) {
  3104. let toastContainer = document.querySelector('.M3Unator-toast-container');
  3105. if (!toastContainer) {
  3106. toastContainer = document.createElement('div');
  3107. toastContainer.className = 'M3Unator-toast-container';
  3108. document.body.appendChild(toastContainer);
  3109. }
  3110.  
  3111. while (toastContainer.firstChild) {
  3112. toastContainer.removeChild(toastContainer.firstChild);
  3113. }
  3114.  
  3115. const toast = document.createElement('div');
  3116. toast.className = `M3Unator-toast ${type}`;
  3117. toast.innerHTML = `${this.icons[type]}<span>${message}</span>`;
  3118.  
  3119. toastContainer.appendChild(toast);
  3120.  
  3121. setTimeout(() => {
  3122. toast.classList.add('removing');
  3123. setTimeout(() => {
  3124. if (toast.parentNode === toastContainer) {
  3125. toastContainer.removeChild(toast);
  3126. }
  3127. if (toastContainer.children.length === 0) {
  3128. document.body.removeChild(toastContainer);
  3129. }
  3130. }, 300);
  3131. }, duration);
  3132. }
  3133.  
  3134. setupPopupHandlers() {
  3135. const generateBtn = this.domElements.generateBtn;
  3136. const playlistInput = this.domElements.playlistInput;
  3137. const includeVideo = this.domElements.includeVideo;
  3138. const includeAudio = this.domElements.includeAudio;
  3139. const recursiveSearch = this.domElements.recursiveSearch;
  3140. const controls = this.domElements.controls;
  3141.  
  3142. const dropdown = this.domElements.dropdown;
  3143. const dropdownButton = dropdown.querySelector('.M3Unator-dropdown-button');
  3144. const dropdownItems = dropdown.querySelectorAll('.M3Unator-dropdown-item');
  3145.  
  3146. const controlButtons = controls.querySelectorAll('.M3Unator-control-btn');
  3147. const pauseBtn = controlButtons[0];
  3148. const resumeBtn = controlButtons[1];
  3149. const cancelBtn = controlButtons[2];
  3150.  
  3151. dropdownButton.addEventListener('click', () => {
  3152. dropdown.classList.toggle('active');
  3153. });
  3154.  
  3155. document.addEventListener('click', (e) => {
  3156. if (!dropdown.contains(e.target)) {
  3157. dropdown.classList.remove('active');
  3158. }
  3159. });
  3160.  
  3161. dropdownItems.forEach(item => {
  3162. item.addEventListener('click', () => {
  3163. dropdownItems.forEach(i => i.classList.remove('selected'));
  3164. item.classList.add('selected');
  3165. dropdownButton.querySelector('span').textContent = item.textContent;
  3166. this.state.selectedFormat = item.dataset.value;
  3167. dropdown.classList.remove('active');
  3168. });
  3169. });
  3170.  
  3171. recursiveSearch.checked = true;
  3172. this.state.recursiveSearch = true;
  3173. includeVideo.checked = true;
  3174. includeAudio.checked = true;
  3175. this.state.includeVideo = true;
  3176. this.state.includeAudio = true;
  3177.  
  3178. includeVideo.addEventListener('change', (e) => {
  3179. this.state.includeVideo = e.target.checked;
  3180. this.addLogEntry(
  3181. e.target.checked ?
  3182. 'Video files will be included' :
  3183. 'Video files will not be included',
  3184. 'info'
  3185. );
  3186. });
  3187.  
  3188. includeAudio.addEventListener('change', (e) => {
  3189. this.state.includeAudio = e.target.checked;
  3190. this.addLogEntry(
  3191. e.target.checked ?
  3192. 'Audio files will be included' :
  3193. 'Audio files will not be included',
  3194. 'info'
  3195. );
  3196. });
  3197.  
  3198. const currentDepth = this.domElements.currentDepth;
  3199. const customDepth = this.domElements.customDepth;
  3200. const maxDepth = this.domElements.maxDepth;
  3201. const depthControls = this.domElements.depthControls;
  3202.  
  3203. depthControls.style.display = 'none';
  3204. depthControls.classList.remove('active');
  3205. this.state.maxDepth = -1;
  3206.  
  3207. currentDepth.checked = true;
  3208. customDepth.checked = false;
  3209. maxDepth.disabled = true;
  3210. maxDepth.value = '1';
  3211.  
  3212. recursiveSearch.addEventListener('change', (e) => {
  3213. if (!e.target.checked) {
  3214. depthControls.style.display = 'block';
  3215. depthControls.classList.add('active');
  3216. currentDepth.checked = true;
  3217. customDepth.checked = false;
  3218. maxDepth.disabled = true;
  3219. this.state.maxDepth = 0;
  3220. this.addLogEntry('Directory scanning disabled, only current directory will be scanned', 'info');
  3221. } else {
  3222. depthControls.style.display = 'none';
  3223. depthControls.classList.remove('active');
  3224. this.state.maxDepth = -1;
  3225. this.state.recursiveSearch = true;
  3226. this.addLogEntry('Directory scanning active, all directories will be scanned', 'info');
  3227. }
  3228. });
  3229.  
  3230. this.domElements.currentDepth.addEventListener('change', (e) => {
  3231. if (e.target.checked && !recursiveSearch.checked) {
  3232. this.state.maxDepth = 0;
  3233. this.domElements.maxDepth.disabled = true;
  3234. this.addLogEntry('Only current directory will be scanned', 'info');
  3235. }
  3236. });
  3237.  
  3238. this.domElements.customDepth.addEventListener('change', (e) => {
  3239. if (e.target.checked && !recursiveSearch.checked) {
  3240. const depthValue = parseInt(this.domElements.maxDepth.value) || 1;
  3241. this.state.maxDepth = depthValue;
  3242. this.domElements.maxDepth.disabled = false;
  3243. this.addLogEntry(
  3244. `Directory scanning depth: ${depthValue} ` +
  3245. `(current directory + ${depthValue} sublevels)`,
  3246. 'info'
  3247. );
  3248. }
  3249. });
  3250.  
  3251. this.domElements.maxDepth.addEventListener('input', (e) => {
  3252. if (this.domElements.customDepth.checked && !recursiveSearch.checked) {
  3253. const value = Math.min(99, Math.max(1, parseInt(e.target.value) || 1));
  3254. e.target.value = value;
  3255. this.state.maxDepth = value;
  3256. this.addLogEntry(
  3257. `Directory scanning depth updated: ${value} ` +
  3258. `(current directory + ${value} sublevels)`,
  3259. 'info'
  3260. );
  3261. }
  3262. });
  3263.  
  3264. pauseBtn.addEventListener('click', () => {
  3265. this.state.isPaused = true;
  3266. pauseBtn.style.display = 'none';
  3267. resumeBtn.style.display = 'flex';
  3268. generateBtn.innerHTML = `
  3269. <div class="M3Unator-spinner" style="animation-play-state: paused;"></div>
  3270. <span>Scan paused</span>
  3271. `;
  3272. this.showToast('Scan paused', 'warning');
  3273. this.addLogEntry('Scan paused...', 'warning');
  3274. });
  3275.  
  3276. resumeBtn.addEventListener('click', () => {
  3277. this.state.isPaused = false;
  3278. resumeBtn.style.display = 'none';
  3279. pauseBtn.style.display = 'flex';
  3280. generateBtn.innerHTML = `
  3281. <div class="M3Unator-spinner"></div>
  3282. <span>Creating...</span>
  3283. `;
  3284. this.showToast('Scan in progress', 'success');
  3285. this.addLogEntry('Scan in progress...', 'success');
  3286. });
  3287.  
  3288. cancelBtn.addEventListener('click', () => {
  3289. this.state.isGenerating = false;
  3290. this.state.isPaused = false;
  3291. setTimeout(() => {
  3292. this.reset({ isCancelled: true, enableToggles: true });
  3293. this.showToast('Scan cancelled', 'warning');
  3294. }, 100);
  3295. });
  3296.  
  3297. generateBtn.addEventListener('click', async () => {
  3298. const playlistName = this.sanitizeInput(playlistInput.value.trim());
  3299.  
  3300. if (!playlistName) {
  3301. this.showToast('Please enter a valid playlist name', 'warning');
  3302. return;
  3303. }
  3304.  
  3305. if (!this.state.includeVideo && !this.state.includeAudio) {
  3306. this.showToast('Please select at least one media type', 'warning');
  3307. return;
  3308. }
  3309.  
  3310. try {
  3311. this.entries = [];
  3312. this.seenUrls.clear();
  3313. this.logCount = 0;
  3314. if (this.domElements.scanLog) {
  3315. this.domElements.scanLog.innerHTML = '';
  3316. }
  3317. if (this.domElements.logCounter) {
  3318. this.domElements.logCounter.textContent = '0';
  3319. }
  3320. this.state.stats = JSON.parse(JSON.stringify(this.initialStats));
  3321.  
  3322. this.state.isGenerating = true;
  3323. generateBtn.disabled = true;
  3324. generateBtn.innerHTML = `
  3325. <div class="M3Unator-spinner"></div>
  3326. <span>Creating...</span>
  3327. `;
  3328.  
  3329. this.domElements.includeVideo.disabled = true;
  3330. this.domElements.includeAudio.disabled = true;
  3331. this.domElements.recursiveSearch.disabled = true;
  3332. this.domElements.currentDepth.disabled = true;
  3333. this.domElements.customDepth.disabled = true;
  3334. this.domElements.maxDepth.disabled = true;
  3335.  
  3336. controls.style.display = 'flex';
  3337. controls.classList.add('active');
  3338. if (pauseBtn) {
  3339. pauseBtn.style.display = 'flex';
  3340. resumeBtn.style.display = 'none';
  3341. cancelBtn.style.display = 'flex';
  3342. }
  3343.  
  3344. this.domElements.statsBar.style.display = 'block';
  3345. this.domElements.statsBar.classList.add('active');
  3346.  
  3347. const entries = await this.scanDirectory(window.location.href, '', 0);
  3348.  
  3349. if (!this.state.isGenerating) {
  3350. return;
  3351. }
  3352.  
  3353. if (entries.length === 0) {
  3354. this.showToast('No media files found', 'error');
  3355. this.reset({ isCancelled: true });
  3356. return;
  3357. }
  3358.  
  3359. this.addLogEntry(`Total ${entries.length} files found.`, 'success');
  3360. this.updateCounter(entries.length);
  3361.  
  3362. const content = this.createPlaylist(entries);
  3363. const fileName = `${playlistName}.${this.state.selectedFormat}`;
  3364.  
  3365. const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
  3366. const url = URL.createObjectURL(blob);
  3367. const a = document.createElement('a');
  3368. a.href = url;
  3369. a.download = fileName;
  3370. document.body.appendChild(a);
  3371. a.click();
  3372. document.body.removeChild(a);
  3373. URL.revokeObjectURL(url);
  3374.  
  3375. this.reset({ keepLogs: true, keepUI: true, enableToggles: true });
  3376.  
  3377. } catch (error) {
  3378. console.error('Error creating playlist:', error);
  3379. this.addLogEntry(`Error: ${error.message}`, 'error');
  3380. this.showToast('Error creating playlist', 'error');
  3381. this.reset({ isCancelled: true });
  3382. }
  3383. });
  3384. }
  3385.  
  3386. reset(options = {}) {
  3387. const {
  3388. isCancelled = false,
  3389. uiOnly = false,
  3390. keepLogs = false,
  3391. keepUI = false,
  3392. enableToggles = false,
  3393. wasGenerating = this.state.isGenerating
  3394. } = options;
  3395.  
  3396. this.state.isGenerating = false;
  3397. this.state.isPaused = false;
  3398. if (!uiOnly) {
  3399. this.entries = [];
  3400. this.seenUrls.clear();
  3401. if (!keepLogs) {
  3402. this.logCount = 0;
  3403. if (this.domElements.scanLog) {
  3404. this.domElements.scanLog.innerHTML = '';
  3405. }
  3406. if (this.domElements.logCounter) {
  3407. this.domElements.logCounter.textContent = '0';
  3408. }
  3409. }
  3410.  
  3411. if (wasGenerating && !isCancelled) {
  3412. const stats = this.domElements.stats;
  3413. const summary = [
  3414. `Scan completed:`,
  3415. `• Video files: ${stats.videoFiles.textContent}`,
  3416. `• Audio files: ${stats.audioFiles.textContent}`,
  3417. `• Scanned directories: ${stats.directories.textContent}`,
  3418. `• Maximum depth: ${stats.depthLevel.textContent}`,
  3419. stats.errors.textContent > 0 ? `• Errors: ${stats.errors.textContent} (${this.state.stats.errors.skipped} skipped)` : null
  3420. ].filter(Boolean).join('\n');
  3421.  
  3422. this.addLogEntry(summary, 'final');
  3423. }
  3424. }
  3425. const elements = this.domElements;
  3426. if (elements.generateBtn) {
  3427. elements.generateBtn.disabled = false;
  3428. elements.generateBtn.innerHTML = `${this.icons.download}<span>Create Playlist</span>`;
  3429. }
  3430.  
  3431. if (elements.controls) {
  3432. elements.controls.style.display = 'none';
  3433. elements.controls.classList.remove('active');
  3434. const pauseBtn = elements.controls.querySelector('.M3Unator-control-btn.pause');
  3435. const resumeBtn = elements.controls.querySelector('.M3Unator-control-btn.resume');
  3436. const cancelBtn = elements.controls.querySelector('.M3Unator-control-btn.cancel');
  3437. if (pauseBtn) pauseBtn.style.display = 'none';
  3438. if (resumeBtn) resumeBtn.style.display = 'none';
  3439. if (cancelBtn) cancelBtn.style.display = 'none';
  3440. }
  3441.  
  3442. if (enableToggles) {
  3443. if (elements.includeVideo) elements.includeVideo.disabled = false;
  3444. if (elements.includeAudio) elements.includeAudio.disabled = false;
  3445. if (elements.recursiveSearch) elements.recursiveSearch.disabled = false;
  3446. if (elements.currentDepth) elements.currentDepth.disabled = false;
  3447. if (elements.customDepth) elements.customDepth.disabled = false;
  3448. if (elements.maxDepth) elements.maxDepth.disabled = elements.customDepth ? !elements.customDepth.checked : true;
  3449. }
  3450. if (uiOnly) return;
  3451.  
  3452. if (isCancelled) {
  3453. this.state.stats = JSON.parse(JSON.stringify(this.initialStats));
  3454.  
  3455. if (!keepLogs) {
  3456. if (elements.scanLog) {
  3457. elements.scanLog.innerHTML = '';
  3458. elements.scanLog.classList.add('collapsed');
  3459. }
  3460.  
  3461. if (elements.logCounter) {
  3462. elements.logCounter.textContent = '0';
  3463. }
  3464.  
  3465. if (elements.logToggle) {
  3466. elements.logToggle.classList.remove('active');
  3467. }
  3468.  
  3469. if (this.domElements.stats) {
  3470. Object.entries(this.domElements.stats).forEach(([key, element]) => {
  3471. if (element) {
  3472. element.textContent = '0';
  3473. const statContainer = element.closest('.M3Unator-stat');
  3474. if (statContainer) {
  3475. statContainer.style.opacity = '0.5';
  3476. if (key === 'depthLevel') {
  3477. statContainer.dataset.progress = '';
  3478. statContainer.title = 'Depth Level: 0';
  3479. }
  3480. }
  3481. }
  3482. });
  3483. }
  3484. }
  3485. }
  3486.  
  3487. if (elements.recursiveSearch) {
  3488. elements.recursiveSearch.checked = true;
  3489. this.state.recursiveSearch = true;
  3490. this.state.maxDepth = -1;
  3491. }
  3492.  
  3493. if (elements.currentDepth) {
  3494. elements.currentDepth.checked = false;
  3495. }
  3496.  
  3497. if (elements.customDepth) {
  3498. elements.customDepth.checked = false;
  3499. }
  3500.  
  3501. if (elements.maxDepth) {
  3502. elements.maxDepth.disabled = true;
  3503. elements.maxDepth.value = '1';
  3504. }
  3505.  
  3506. if (elements.depthControls) {
  3507. elements.depthControls.classList.remove('active');
  3508. }
  3509. }
  3510.  
  3511. handleError(error, context = '') {
  3512. let userMessage = 'An error occurred';
  3513. let logMessage = error.message;
  3514. let type = 'error';
  3515.  
  3516. switch (true) {
  3517. case error.name === 'AbortError':
  3518. userMessage = 'Server not responding, operation timed out';
  3519. logMessage = `Timeout: ${context}`;
  3520. type = 'warning';
  3521. break;
  3522.  
  3523. case error.message.includes('HTTP error'):
  3524. const status = error.message.match(/\d+/)?.[0];
  3525. switch (status) {
  3526. case '403':
  3527. userMessage = 'Access denied to this directory';
  3528. break;
  3529. case '404':
  3530. userMessage = 'Directory or file not found';
  3531. break;
  3532. case '429':
  3533. userMessage = 'Too many requests, please wait a while';
  3534. break;
  3535. case '500':
  3536. case '502':
  3537. case '503':
  3538. userMessage = 'Server is currently unable to respond, please try again later';
  3539. break;
  3540. default:
  3541. userMessage = 'Error communicating with server';
  3542. }
  3543. logMessage = `${error.message} (${context})`;
  3544. break;
  3545.  
  3546. case error.message.includes('decode'):
  3547. userMessage = 'Filename or path could not be read';
  3548. logMessage = `Decode error: ${context} - ${error.message}`;
  3549. type = 'warning';
  3550. break;
  3551.  
  3552. case error.message.includes('NetworkError'):
  3553. userMessage = 'Network connection error, please check your connection';
  3554. logMessage = `Network error: ${context}`;
  3555. break;
  3556.  
  3557. case error.message.includes('SecurityError'):
  3558. userMessage = 'Operation not allowed due to security restrictions';
  3559. logMessage = `Security error: ${context}`;
  3560. break;
  3561.  
  3562. default:
  3563. userMessage = 'Unexpected error occurred';
  3564. logMessage = `${error.name}: ${error.message} (${context})`;
  3565. }
  3566.  
  3567. console.error(`[${context}]`, error);
  3568.  
  3569. this.showToast(userMessage, type);
  3570.  
  3571. this.addLogEntry(logMessage, type);
  3572.  
  3573. this.state.stats.errors.total++;
  3574. }
  3575.  
  3576. async fetchWithRetry(url, options = {}) {
  3577. let response;
  3578. let retryCount = 0;
  3579. const maxRetries = this.state.retryCount;
  3580. const baseTimeout = 1000;
  3581. const maxTimeout = 10000;
  3582.  
  3583. while (retryCount <= maxRetries) {
  3584. try {
  3585. const controller = new AbortController();
  3586. const currentTimeout = Math.min(
  3587. maxTimeout,
  3588. baseTimeout * Math.pow(2, retryCount) * (0.5 + Math.random())
  3589. );
  3590. const timeoutId = setTimeout(() => controller.abort(), currentTimeout);
  3591.  
  3592. response = await fetch(url, {
  3593. ...options,
  3594. signal: controller.signal,
  3595. headers: {
  3596. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  3597. 'Accept-Charset': 'utf-8',
  3598. 'Accept-Language': 'en-US,en;q=0.9,tr-TR;q=0.8,tr;q=0.7'
  3599. }
  3600. });
  3601.  
  3602. clearTimeout(timeoutId);
  3603.  
  3604. if (response.ok) {
  3605. const contentType = response.headers.get('content-type');
  3606. const charset = contentType && contentType.includes('charset=')
  3607. ? contentType.split('charset=')[1].toLowerCase()
  3608. : 'utf-8';
  3609.  
  3610. const buffer = await response.arrayBuffer();
  3611. const decoder = new TextDecoder(charset);
  3612. response.decodedText = decoder.decode(buffer);
  3613.  
  3614. return response;
  3615. }
  3616.  
  3617. throw new Error(`HTTP error! Status: ${response.status}`);
  3618. } catch (error) {
  3619. retryCount++;
  3620. this.handleError(error, `URL: ${url}`);
  3621.  
  3622. if (retryCount > maxRetries) {
  3623. this.addLogEntry(
  3624. `Maximum number of attempts reached (${maxRetries}), skipping directory: ${url}`,
  3625. 'error'
  3626. );
  3627. this.state.stats.errors.skipped++;
  3628. throw error;
  3629. }
  3630.  
  3631. const backoffDelay = Math.min(
  3632. maxTimeout,
  3633. baseTimeout * Math.pow(2, retryCount - 1) * (0.5 + Math.random())
  3634. );
  3635.  
  3636. this.addLogEntry(
  3637. `Retrying (${retryCount}/${maxRetries}), waiting for ${(backoffDelay/1000).toFixed(1)} seconds...`,
  3638. 'warning'
  3639. );
  3640.  
  3641. await new Promise(resolve => setTimeout(resolve, backoffDelay));
  3642. }
  3643. }
  3644. }
  3645.  
  3646. sanitizeInput(input) {
  3647. if (!input || typeof input !== 'string') {
  3648. return '';
  3649. }
  3650.  
  3651. const sanitized = input
  3652. .replace(/[<>:"\/\\|?*\x00-\x1F]/g, '')
  3653. .trim()
  3654. .replace(/[\x00-\x1F\x7F]/g, '')
  3655. .replace(/[\u200B-\u200D\uFEFF]/g, '')
  3656. .replace(/[^\w\s\-_.()[\]{}#@!$%^&+=]/g, '');
  3657.  
  3658. if (!sanitized) {
  3659. return 'playlist';
  3660. }
  3661.  
  3662. if (sanitized.length > 255) {
  3663. return sanitized.slice(0, 255);
  3664. }
  3665.  
  3666. return sanitized;
  3667. }
  3668.  
  3669. decodeString(str, type = 'both') {
  3670. if (!str) return str;
  3671. try {
  3672. let decoded = str;
  3673. if (type === 'html' || type === 'both') {
  3674. decoded = decoded.replace(/&amp;/g, '&')
  3675. .replace(/&lt;/g, '<')
  3676. .replace(/&gt;/g, '>')
  3677. .replace(/&quot;/g, '"')
  3678. .replace(/&#039;/g, "'")
  3679. .replace(/&#x27;/g, "'")
  3680. .replace(/&#x2F;/g, "/");
  3681. }
  3682.  
  3683. if (type === 'url' || type === 'both') {
  3684. try {
  3685. decoded = decodeURIComponent(decoded);
  3686. } catch (e) {
  3687. decoded = decoded.replace(/%([0-9A-F]{2})/gi, (match, hex) => {
  3688. try {
  3689. return String.fromCharCode(parseInt(hex, 16));
  3690. } catch {
  3691. return match;
  3692. }
  3693. });
  3694. }
  3695. }
  3696. return decoded;
  3697. } catch (error) {
  3698. console.warn('Decode error:', error);
  3699. return str;
  3700. }
  3701. }
  3702.  
  3703. extractFileInfo(path) {
  3704. try {
  3705. const decodedPath = this.decodeString(path);
  3706. const parts = decodedPath.split('/');
  3707. const fileName = parts.pop() || '';
  3708. const dirPath = parts.join('/');
  3709. return {
  3710. fileName,
  3711. dirPath,
  3712. original: {
  3713. fileName: path.split('/').pop() || '',
  3714. dirPath: path.split('/').slice(0, -1).join('/')
  3715. }
  3716. };
  3717. } catch (error) {
  3718. this.handleError(error, `Path decode error: ${path}`);
  3719. const parts = path.split('/');
  3720. return {
  3721. fileName: parts.pop() || '',
  3722. dirPath: parts.join('/'),
  3723. original: {
  3724. fileName: parts.pop() || '',
  3725. dirPath: parts.join('/')
  3726. }
  3727. };
  3728. }
  3729. }
  3730.  
  3731. normalizeUrl(url) {
  3732. let normalized = url.replace(/([^:]\/)\/+/g, "$1");
  3733. return normalized.endsWith('/') ? normalized : normalized + '/';
  3734. }
  3735.  
  3736. isMediaFile(fileName, type) {
  3737. const lowerFileName = fileName.toLowerCase();
  3738. return type === 'video'
  3739. ? this.videoFormats.some(ext => lowerFileName.endsWith(ext))
  3740. : this.audioFormats.some(ext => lowerFileName.endsWith(ext));
  3741. }
  3742.  
  3743. resetCurrentStats() {
  3744. this.state.stats.files.video.current = 0;
  3745. this.state.stats.files.audio.current = 0;
  3746. }
  3747.  
  3748. updateFileStats(type) {
  3749. this.state.stats.files[type].total++;
  3750. this.state.stats.files[type].current++;
  3751. }
  3752.  
  3753. getCurrentStatsText() {
  3754. const { video, audio } = this.state.stats.files;
  3755. const details = [];
  3756.  
  3757. if (video.current > 0) details.push(`${video.current} video`);
  3758. if (audio.current > 0) details.push(`${audio.current} audio`);
  3759.  
  3760. return details.join(' and ');
  3761. }
  3762.  
  3763. async scanDirectory(url, currentPath = '', depth = 0) {
  3764. try {
  3765. this.resetCurrentStats();
  3766.  
  3767. if (!this.state.isGenerating || this.entries.length >= this.state.maxEntries) {
  3768. return this.entries;
  3769. }
  3770.  
  3771. while (this.state.isPaused && this.state.isGenerating) {
  3772. await new Promise(resolve => setTimeout(resolve, 100));
  3773. }
  3774.  
  3775. const normalizedUrl = this.normalizeUrl(url);
  3776.  
  3777. if (depth > this.state.stats.directories.depth) {
  3778. this.state.stats.directories.depth = depth;
  3779. }
  3780.  
  3781. this.state.stats.directories.total++;
  3782.  
  3783. this.addLogEntry(`Scanning directory (${depth}. level): ${normalizedUrl}`);
  3784.  
  3785. if (this.seenUrls.has(normalizedUrl)) {
  3786. this.addLogEntry(`Directory already scanned: ${normalizedUrl}`);
  3787. return this.entries;
  3788. }
  3789.  
  3790. this.seenUrls.add(normalizedUrl);
  3791. if (this.seenUrls.size > this.state.maxSeenUrls) {
  3792. const keepCount = Math.floor(this.state.maxSeenUrls * 0.75);
  3793. const urlsArray = Array.from(this.seenUrls);
  3794. const keepUrls = urlsArray.slice(-keepCount);
  3795. this.seenUrls = new Set(keepUrls);
  3796. this.addLogEntry(
  3797. `Cache cleared (${urlsArray.length} -> ${keepUrls.length})`,
  3798. 'info'
  3799. );
  3800. }
  3801.  
  3802. let response;
  3803. try {
  3804. response = await this.fetchWithRetry(normalizedUrl);
  3805. } catch (error) {
  3806. return this.entries;
  3807. }
  3808.  
  3809. const html = response.decodedText;
  3810. const parser = new DOMParser();
  3811. const doc = parser.parseFromString(html, 'text/html');
  3812. // Handle LiteSpeed directory listing
  3813. const isLiteSpeed = doc.querySelector('div#table-list') !== null;
  3814. let hrefs = [];
  3815. if (isLiteSpeed) {
  3816. const rows = doc.querySelectorAll('#table-content tr');
  3817. rows.forEach(row => {
  3818. const link = row.querySelector('a');
  3819. if (link && !link.textContent.includes('Parent Directory')) {
  3820. const href = link.getAttribute('href');
  3821. if (href) hrefs.push(href);
  3822. }
  3823. });
  3824. } else {
  3825. // Handle Apache/Nginx style directory listing
  3826. const hrefRegex = /href="([^"]+)"/gi;
  3827. const matches = html.matchAll(hrefRegex);
  3828. hrefs = Array.from(matches, m => m[1]).filter(href =>
  3829. href &&
  3830. !href.startsWith('?') &&
  3831. !href.startsWith('/') &&
  3832. href !== '../' &&
  3833. !href.includes('Parent Directory')
  3834. );
  3835. }
  3836.  
  3837. let totalFilesInCurrentDir = 0;
  3838.  
  3839. for (const href of hrefs) {
  3840. if (!this.state.isGenerating || this.entries.length >= this.state.maxEntries) break;
  3841.  
  3842. try {
  3843. const decodedHref = this.decodeString(href);
  3844. const fullUrl = new URL(decodedHref, normalizedUrl).toString();
  3845. const { fileName } = this.extractFileInfo(decodedHref);
  3846. const fullPath = currentPath ? `${currentPath}/${fileName}` : fileName;
  3847.  
  3848. if (href.endsWith('/')) {
  3849. const shouldScanSubdir =
  3850. this.state.maxDepth === -1 ||
  3851. (this.state.maxDepth > 0 && depth < this.state.maxDepth);
  3852. if (shouldScanSubdir) {
  3853. this.addLogEntry(`Entering directory: ${fullPath}`);
  3854. await this.scanDirectory(fullUrl, fullPath, depth + 1);
  3855. }
  3856. } else {
  3857. totalFilesInCurrentDir++;
  3858. this.state.stats.totalFiles = (this.state.stats.totalFiles || 0) + 1;
  3859.  
  3860. const isVideo = this.isMediaFile(fileName, 'video');
  3861. const isAudio = this.isMediaFile(fileName, 'audio');
  3862.  
  3863. if ((isVideo && this.state.includeVideo) || (isAudio && this.state.includeAudio)) {
  3864. if (isVideo && this.state.includeVideo) {
  3865. this.updateFileStats('video');
  3866. }
  3867. if (isAudio && this.state.includeAudio) {
  3868. this.updateFileStats('audio');
  3869. }
  3870.  
  3871. this.entries.push({
  3872. title: fullPath,
  3873. url: fullUrl
  3874. });
  3875. }
  3876. }
  3877. this.updateCounter(this.state.stats.totalFiles);
  3878. } catch (error) {
  3879. console.error('Error processing URL:', error);
  3880. this.state.stats.errors.total++;
  3881. continue;
  3882. }
  3883. }
  3884.  
  3885. if (totalFilesInCurrentDir > 0) {
  3886. this.addLogEntry(
  3887. `"${currentPath || normalizedUrl}" directory contains ${totalFilesInCurrentDir} files`,
  3888. 'info'
  3889. );
  3890. }
  3891.  
  3892. const statsText = this.getCurrentStatsText();
  3893. if (statsText) {
  3894. this.addLogEntry(
  3895. `From these, ${statsText} files were added to the playlist`,
  3896. 'success'
  3897. );
  3898. }
  3899.  
  3900. return this.entries;
  3901. } catch (error) {
  3902. this.state.stats.errors.total++;
  3903. this.addLogEntry(`Scan error (${currentPath || url}): ${error.message}`, 'error');
  3904. return this.entries;
  3905. }
  3906. }
  3907.  
  3908. createPlaylist(entries) {
  3909. let content = '#EXTM3U\n';
  3910. const decodedEntries = entries.map(entry => {
  3911. try {
  3912. let title = this.decodeString(entry.title);
  3913. const depth = (title.match(/\//g) || []).length;
  3914. const isVideo = this.videoFormats.some(ext => title.toLowerCase().endsWith(ext));
  3915. const isAudio = this.audioFormats.some(ext => title.toLowerCase().endsWith(ext));
  3916. return {
  3917. ...entry,
  3918. decodedTitle: title,
  3919. depth: depth,
  3920. isVideo: isVideo,
  3921. isAudio: isAudio
  3922. };
  3923. } catch (error) {
  3924. return {
  3925. ...entry,
  3926. decodedTitle: entry.title,
  3927. depth: 0,
  3928. isVideo: false,
  3929. isAudio: false
  3930. };
  3931. }
  3932. });
  3933.  
  3934. const videoEntries = decodedEntries.filter(entry => entry.isVideo);
  3935. const audioEntries = decodedEntries.filter(entry => entry.isAudio);
  3936.  
  3937. const apacheSort = (a, b) => {
  3938. if (a.depth !== b.depth) {
  3939. return a.depth - b.depth;
  3940. }
  3941.  
  3942. const aStartsWithNumber = /^\d/.test(a.decodedTitle);
  3943. const bStartsWithNumber = /^\d/.test(b.decodedTitle);
  3944. if (aStartsWithNumber !== bStartsWithNumber) {
  3945. return aStartsWithNumber ? -1 : 1;
  3946. }
  3947.  
  3948. return a.decodedTitle.localeCompare(b.decodedTitle, undefined, {
  3949. numeric: true,
  3950. sensitivity: 'base'
  3951. });
  3952. };
  3953.  
  3954. const sortedVideoEntries = videoEntries.sort(apacheSort);
  3955. const sortedAudioEntries = audioEntries.sort(apacheSort);
  3956.  
  3957. const sortedEntries = [...sortedVideoEntries, ...sortedAudioEntries];
  3958.  
  3959. sortedEntries.forEach(entry => {
  3960. content += `#EXTINF:-1,${entry.decodedTitle}\n${entry.url}\n`;
  3961. });
  3962.  
  3963. return content;
  3964. }
  3965.  
  3966. addLogEntry(message, type = '') {
  3967.  
  3968. if ((this.state.isPaused || !this.state.isGenerating) && type !== 'final') {
  3969. return;
  3970. }
  3971.  
  3972. const scanLog = this.domElements.scanLog;
  3973. const logCounter = this.domElements.logCounter;
  3974. this.logCount++;
  3975. if (logCounter) {
  3976. logCounter.textContent = this.logCount;
  3977. }
  3978. let decodedMessage = message;
  3979. try {
  3980. if (message.includes('http')) {
  3981. const urlRegex = /(https?:\/\/[^\s]+)/g;
  3982. decodedMessage = message.replace(urlRegex, (url) => {
  3983. try {
  3984. return decodeURIComponent(url);
  3985. } catch (e) {
  3986. return url;
  3987. }
  3988. });
  3989. }
  3990. } catch (error) {
  3991. console.warn('Decode error:', error);
  3992. }
  3993. const entry = document.createElement('div');
  3994. entry.className = `M3Unator-log-entry ${type}`;
  3995.  
  3996. const timestamp = new Date().toLocaleTimeString();
  3997. entry.innerHTML = `<span class="M3Unator-log-time">[${timestamp}]</span> ${decodedMessage}`;
  3998. scanLog.appendChild(entry);
  3999. scanLog.scrollTop = scanLog.scrollHeight;
  4000. }
  4001.  
  4002. updateCounter(count) {
  4003. if (!this.domElements.stats || !this.domElements.statsBar) {
  4004. return;
  4005. }
  4006.  
  4007. const stats = this.state.stats;
  4008. const elements = this.domElements.stats;
  4009. const statsBar = this.domElements.statsBar;
  4010.  
  4011. statsBar.style.display = 'block';
  4012. const updates = {
  4013. 'totalFiles': count,
  4014. 'videoFiles': stats.files.video.total,
  4015. 'audioFiles': stats.files.audio.total,
  4016. 'directories': stats.directories.total,
  4017. 'depthLevel': stats.directories.depth,
  4018. 'errors': stats.errors.total
  4019. };
  4020.  
  4021. Object.entries(updates).forEach(([key, value]) => {
  4022. const element = elements[key];
  4023. if (element) {
  4024. element.textContent = value;
  4025. const statContainer = element.closest('.M3Unator-stat');
  4026. if (statContainer) {
  4027. statContainer.style.opacity = value > 0 ? '1' : '0.5';
  4028. if (key === 'depthLevel') {
  4029. const maxDepth = this.state.maxDepth || 0;
  4030. if (maxDepth > 0) {
  4031. const progress = (value / maxDepth) * 100;
  4032. statContainer.dataset.progress =
  4033. progress >= 100 ? 'high' :
  4034. progress >= 75 ? 'medium' :
  4035. progress >= 50 ? 'low' : '';
  4036. statContainer.title = `Depth Level: ${value}/${maxDepth}`;
  4037. } else {
  4038. statContainer.dataset.progress = '';
  4039. statContainer.title = `Depth Level: ${value}`;
  4040. }
  4041. }
  4042. }
  4043. }
  4044. });
  4045. }
  4046. }
  4047.  
  4048. const generator = new PlaylistGenerator();
  4049. generator.init();
  4050.  
  4051. // Event listeners for info modal
  4052. document.querySelector('.info-link').addEventListener('click', () => {
  4053. document.querySelector('.info-modal').style.display = 'block';
  4054. document.body.classList.add('modal-open');
  4055. });
  4056.  
  4057. document.querySelector('.info-close').addEventListener('click', () => {
  4058. document.querySelector('.info-modal').style.display = 'none';
  4059. document.body.classList.remove('modal-open');
  4060. });
  4061.  
  4062. window.addEventListener('click', (event) => {
  4063. const modal = document.querySelector('.info-modal');
  4064. if (event.target === modal) {
  4065. modal.style.display = 'none';
  4066. document.body.classList.remove('modal-open');
  4067. }
  4068. });
  4069.  
  4070. // Event listener for playlist name input
  4071. generator.domElements.playlistInput.addEventListener('input', (e) => {
  4072. const dropdown = e.target.parentElement.querySelector('.M3Unator-dropdown');
  4073. if (e.target.value.trim()) {
  4074. dropdown.style.display = 'block';
  4075. } else {
  4076. dropdown.style.display = 'none';
  4077. }
  4078. });
  4079. })();