Fullchan X

8chan features script

当前为 2025-04-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fullchan X
  3. // @namespace Violentmonkey Scripts
  4. // @match https://8chan.moe/*/res/*
  5. // @match https://8chan.se/*/res/*
  6. // @match https://8chan.moe/*/catalog*
  7. // @match https://8chan.se/*/catalog*
  8. // @run-at document-end
  9. // @grant none
  10. // @version 1.8.1
  11. // @author vfyxe
  12. // @description 8chan features script
  13. // ==/UserScript==
  14.  
  15. class fullChanX extends HTMLElement {
  16. constructor() {
  17. super();
  18. this.settingsEl = document.querySelector('fullchan-x-settings');
  19. this.settings = this.settingsEl.settings;
  20. this.isThread = !!document.querySelector('.opCell');
  21. this.isDisclaimer = window.location.href.includes('disclaimer');
  22. Object.keys(this.settings).forEach(key => {
  23. this[key] = this.settings[key]?.value;
  24. });
  25. }
  26.  
  27. init() {
  28. this.settingsButton = this.querySelector('#fcx-settings-btn');
  29. this.settingsButton.addEventListener('click', () => this.settingsEl.toggle());
  30. this.handleBoardLinks();
  31. if (!this.isThread) return;
  32.  
  33. this.quickReply = document.querySelector('#quick-reply');
  34. this.qrbody = document.querySelector('#qrbody');
  35. this.threadParent = document.querySelector('#divThreads');
  36. this.threadId = this.threadParent.querySelector('.opCell').id;
  37. this.thread = this.threadParent.querySelector('.divPosts');
  38. this.posts = [...this.thread.querySelectorAll('.postCell')];
  39. this.postOrder = 'default';
  40. this.postOrderSelect = this.querySelector('#thread-sort');
  41. this.myYousLabel = this.querySelector('.my-yous__label');
  42. this.yousContainer = this.querySelector('#my-yous');
  43.  
  44. this.gallery = document.querySelector('fullchan-x-gallery');
  45. this.galleryButton = this.querySelector('#fcx-gallery-btn');
  46.  
  47. this.updateYous();
  48. this.observers();
  49.  
  50. if (this.enableFileExtentions) this.handleTruncatedFilenames();
  51. }
  52.  
  53. styleUI () {
  54. this.style.setProperty('--top', this.uiTopPosition);
  55. this.style.setProperty('--right', this.uiRightPosition);
  56. this.classList.toggle('fcx--dim', this.uiDimWhenInactive);
  57. this.classList.toggle('page-thread', this.isThread);
  58. const style = document.createElement('style');
  59.  
  60. if (this.hideDefaultBoards !== '') {
  61. style.textContent += '#navTopBoardsSpan{display:block!important;}'
  62. }
  63. document.body.appendChild(style);
  64. }
  65.  
  66. handleBoardLinks () {
  67. const navBoards = document.querySelector('#navTopBoardsSpan');
  68. const customBoardLinks = this.customBoardLinks?.toLowerCase().replace(/\s/g,'').split(',');
  69. let hideDefaultBoards = this.hideDefaultBoards?.toLowerCase().replace(/\s/g,'') || '';
  70. const urlCatalog = this.catalogBoardLinks ? '/catalog.html' : '';
  71.  
  72.  
  73. if (hideDefaultBoards === 'all') {
  74. navBoards.classList.add('hidden');
  75. } else {
  76. const waitForNavBoards = setInterval(() => {
  77. const navBoards = document.querySelector('#navTopBoardsSpan');
  78. if (!navBoards || !navBoards.querySelector('a')) return;
  79.  
  80. clearInterval(waitForNavBoards);
  81.  
  82. hideDefaultBoards = hideDefaultBoards.split(',');
  83. const defaultLinks = [...navBoards.querySelectorAll('a')];
  84. defaultLinks.forEach(link => {
  85. link.href += urlCatalog;
  86. const linkText = link.textContent;
  87. const shouldHide = hideDefaultBoards.includes(linkText) || customBoardLinks.includes(linkText);
  88. link.classList.toggle('hidden', shouldHide);
  89. });
  90. }, 50);
  91. }
  92.  
  93. if (this.customBoardLinks.length > 0) {
  94. const customNav = document.createElement('span');
  95. customNav.classList = 'nav-boards nav-boards--custom';
  96. customNav.innerHTML = '<span>[</span>';
  97.  
  98. customBoardLinks.forEach((board, index) => {
  99. const link = document.createElement('a');
  100. link.href = '/' + board + urlCatalog;
  101. link.textContent = board;
  102. customNav.appendChild(link);
  103. if (index < customBoardLinks.length - 1) customNav.innerHTML += '<span>/</span>';
  104. });
  105.  
  106. customNav.innerHTML += '<span>]</span>';
  107. navBoards.parentNode.insertBefore(customNav, navBoards);
  108. }
  109. }
  110.  
  111. observers () {
  112. this.postOrderSelect.addEventListener('change', (event) => {
  113. this.postOrder = event.target.value;
  114. this.assignPostOrder();
  115. });
  116.  
  117. const observerCallback = (mutationsList, observer) => {
  118. for (const mutation of mutationsList) {
  119. if (mutation.type === 'childList') {
  120. this.posts = [...this.thread.querySelectorAll('.postCell')];
  121. if (this.postOrder !== 'default') this.assignPostOrder();
  122. this.updateYous();
  123. this.gallery.updateGalleryImages();
  124. if (this.settings.enableFileExtentions) this.handleTruncatedFilenames();
  125. }
  126. }
  127. };
  128.  
  129. const threadObserver = new MutationObserver(observerCallback);
  130. threadObserver.observe(this.thread, { childList: true, subtree: false });
  131.  
  132. if (this.enableNestedQuotes) {
  133. this.thread.addEventListener('click', event => {
  134. this.handleClick(event);
  135. });
  136. }
  137.  
  138. this.galleryButton.addEventListener('click', () => this.gallery.open());
  139. this.myYousLabel.addEventListener('click', (event) => {
  140. if (this.myYousLabel.classList.contains('unseen')) {
  141. this.yousContainer.querySelector('.unseen').click();
  142. }
  143. });
  144. }
  145.  
  146. handleClick (event) {
  147. const clicked = event.target;
  148.  
  149. const post = clicked.closest('.innerPost') || clicked.closest('.innerOP');
  150. if (!post) return;
  151.  
  152. const isNested = !!post.closest('.innerNested');
  153. const nestQuote = clicked.closest('.quoteLink') || clicked.closest('.panelBacklinks a');
  154. const postMedia = clicked.closest('a[data-filemime]');
  155. const postId = clicked.closest('.linkQuote');
  156.  
  157. if (nestQuote) {
  158. event.preventDefault();
  159. this.nestQuote(nestQuote, post);
  160. } else if (postMedia && isNested) {
  161. this.handleMediaClick(event, postMedia);
  162. } else if (postId && isNested) {
  163. this.handleIdClick(postId);
  164. }
  165. }
  166.  
  167. handleMediaClick (event, postMedia) {
  168. if (postMedia.dataset.filemime === "video/webm") return;
  169. event.preventDefault();
  170. const imageSrc = `${postMedia.href}`;
  171. const imageEl = postMedia.querySelector('img');
  172. if (!postMedia.dataset.thumbSrc) postMedia.dataset.thumbSrc = `${imageEl.src}`;
  173.  
  174. const isExpanding = imageEl.src !== imageSrc;
  175.  
  176. if (isExpanding) {
  177. imageEl.src = imageSrc;
  178. imageEl.classList
  179. }
  180. imageEl.src = isExpanding ? imageSrc : postMedia.dataset.thumbSrc;
  181. imageEl.classList.toggle('imgExpanded', isExpanding);
  182. }
  183.  
  184. handleIdClick (postId) {
  185. const idNumber = '>>' + postId.textContent;
  186. this.quickReply.style.display = 'block';
  187. this.qrbody.value += idNumber + '\n';
  188. }
  189.  
  190. handleTruncatedFilenames () {
  191. this.postFileNames = [...this.threadParent.querySelectorAll('.originalNameLink[download]:not([data-file-ext])')];
  192. this.postFileNames.forEach(fileName => {
  193. const strings = fileName.textContent.split('.');
  194. fileName.textContent = strings[0];
  195. fileName.dataset.fileExt = `.${strings[1]}`;
  196. const typeEl = document.createElement('a');
  197. typeEl.textContent = `.${strings[1]}`;
  198. typeEl.classList = ('file-ext originalNameLink');
  199. fileName.parentNode.insertBefore(typeEl, fileName.nextSibling);
  200. });
  201. }
  202.  
  203. assignPostOrder () {
  204. const postOrderReplies = (post) => {
  205. const replyCount = post.querySelectorAll('.panelBacklinks a').length;
  206. post.style.order = 100 - replyCount;
  207. }
  208.  
  209. const postOrderCatbox = (post) => {
  210. const postContent = post.querySelector('.divMessage').textContent;
  211. const matches = postContent.match(/catbox\.moe/g);
  212. const catboxCount = matches ? matches.length : 0;
  213. post.style.order = 100 - catboxCount;
  214. }
  215.  
  216. if (this.postOrder === 'default') {
  217. this.thread.style.display = 'block';
  218. return;
  219. }
  220.  
  221. this.thread.style.display = 'flex';
  222.  
  223. if (this.postOrder === 'replies') {
  224. this.posts.forEach(post => postOrderReplies(post));
  225. } else if (this.postOrder === 'catbox') {
  226. this.posts.forEach(post => postOrderCatbox(post));
  227. }
  228. }
  229.  
  230. updateYous () {
  231. this.yous = this.posts.filter(post => post.querySelector('.quoteLink.you'));
  232. this.yousLinks = this.yous.map(you => {
  233. const youLink = document.createElement('a');
  234. youLink.textContent = '>>' + you.id;
  235. youLink.href = '#' + you.id;
  236. return youLink;
  237. })
  238.  
  239. let hasUnseenYous = false;
  240. this.setUnseenYous();
  241.  
  242. this.yousContainer.innerHTML = '';
  243. this.yousLinks.forEach(you => {
  244. const youId = you.textContent.replace('>>', '');
  245. if (!this.seenYous.includes(youId)) {
  246. you.classList.add('unseen');
  247. hasUnseenYous = true
  248. }
  249. this.yousContainer.appendChild(you)
  250. });
  251.  
  252. this.myYousLabel.classList.toggle('unseen', hasUnseenYous);
  253.  
  254. if (this.replyTabIcon === '') return;
  255. const icon = this.replyTabIcon;
  256. document.title = hasUnseenYous
  257. ? document.title.startsWith(`${icon} `)
  258. ? document.title
  259. : `${icon} ${document.title}`
  260. : document.title.replace(new RegExp(`^${icon} `), '');
  261. }
  262.  
  263. observeUnseenYou(you) {
  264. you.classList.add('observe-you');
  265.  
  266. const observer = new IntersectionObserver((entries, observer) => {
  267. entries.forEach(entry => {
  268. if (entry.isIntersecting) {
  269. const id = you.id;
  270. you.classList.remove('observe-you');
  271.  
  272. if (!this.seenYous.includes(id)) {
  273. this.seenYous.push(id);
  274. localStorage.setItem(this.seenKey, JSON.stringify(this.seenYous));
  275. }
  276.  
  277. observer.unobserve(you);
  278. this.updateYous();
  279.  
  280. }
  281. });
  282. }, { rootMargin: '0px', threshold: 0.1 });
  283.  
  284. observer.observe(you);
  285. }
  286.  
  287. setUnseenYous() {
  288. this.seenKey = `${this.threadId}-seen-yous`;
  289. this.seenYous = JSON.parse(localStorage.getItem(this.seenKey));
  290.  
  291. if (!this.seenYous) {
  292. this.seenYous = [];
  293. localStorage.setItem(this.seenKey, JSON.stringify(this.seenYous));
  294. }
  295.  
  296. this.unseenYous = this.yous.filter(you => !this.seenYous.includes(you.id));
  297.  
  298. this.unseenYous.forEach(you => {
  299. if (!you.classList.contains('observe-you')) {
  300. this.observeUnseenYou(you);
  301. }
  302. });
  303. }
  304.  
  305. nestQuote(quoteLink, parentPost) {
  306. const parentPostMessage = parentPost.querySelector('.divMessage');
  307. const quoteId = quoteLink.href.split('#')[1];
  308. const quotePost = document.getElementById(quoteId);
  309. if (!quotePost) return;
  310.  
  311. const quotePostContent = quotePost.querySelector('.innerOP') || quotePost.querySelector('.innerPost');
  312. if (!quotePostContent) return;
  313.  
  314. const existing = parentPost.querySelector(`.nestedPost[data-quote-id="${quoteId}"]`);
  315. if (existing) {
  316. existing.remove();
  317. return;
  318. }
  319.  
  320. const isReply = !quoteLink.classList.contains('quoteLink');
  321.  
  322. const wrapper = document.createElement('div');
  323. wrapper.classList.add('nestedPost');
  324. wrapper.setAttribute('data-quote-id', quoteId);
  325.  
  326. const clone = quotePostContent.cloneNode(true);
  327. clone.style.whiteSpace = 'unset';
  328. clone.classList.add('innerNested');
  329. wrapper.appendChild(clone);
  330.  
  331. if (isReply) {
  332. parentPostMessage.insertBefore(wrapper, parentPostMessage.firstChild);
  333. } else {
  334. quoteLink.insertAdjacentElement('afterend', wrapper);
  335. }
  336.  
  337. this.setPostListeners(wrapper);
  338. }
  339.  
  340. setPostListeners(parentPost) {
  341. const postLinks = [
  342. ...parentPost.querySelectorAll('.quoteLink'),
  343. ...parentPost.querySelectorAll('.panelBacklinks a')
  344. ];
  345.  
  346. const hoverPost = (event, link) => {
  347. const quoteId = link.href.split('#')[1];
  348.  
  349. let existingPost = document.querySelector(`.nestedPost[data-quote-id="${quoteId}"]`)
  350. || link.closest(`.postCell[id="${quoteId}"]`);
  351.  
  352. if (existingPost) {
  353. this.markedPost = existingPost.querySelector('.innerPost') || existingPost.querySelector('.innerOP');
  354. this.markedPost?.classList.add('markedPost');
  355. return;
  356. }
  357.  
  358. const quotePost = document.getElementById(quoteId);
  359.  
  360. tooltips.removeIfExists();
  361.  
  362. const tooltip = document.createElement('div');
  363. tooltip.className = 'quoteTooltip';
  364. document.body.appendChild(tooltip);
  365.  
  366. const rect = link.getBoundingClientRect();
  367. if (!api.mobile) {
  368. if (rect.left > window.innerWidth / 2) {
  369. const right = window.innerWidth - rect.left - window.scrollX;
  370. tooltip.style.right = `${right}px`;
  371. } else {
  372. const left = rect.right + 10 + window.scrollX;
  373. tooltip.style.left = `${left}px`;
  374. }
  375. }
  376.  
  377. tooltip.style.top = `${rect.top + window.scrollY}px`;
  378. tooltip.style.display = 'inline';
  379.  
  380. tooltips.loadTooltip(tooltip, link.href, quoteId);
  381. tooltips.currentTooltip = tooltip;
  382. }
  383.  
  384. const unHoverPost = (event, link) => {
  385. if (!tooltips.currentTooltip) {
  386. this.markedPost?.classList.remove('markedPost');
  387. return false;
  388. }
  389.  
  390. if (tooltips.unmarkReply) {
  391. tooltips.currentTooltip.classList.remove('markedPost');
  392. Array.from(tooltips.currentTooltip.getElementsByClassName('replyUnderline'))
  393. .forEach((a) => a.classList.remove('replyUnderline'))
  394. tooltips.unmarkReply = false;
  395. } else {
  396. tooltips.currentTooltip.remove();
  397. }
  398.  
  399. tooltips.currentTooltip = null;
  400. }
  401.  
  402. const addHoverPost = (link => {
  403. link.addEventListener('mouseenter', (event) => hoverPost(event, link));
  404. link.addEventListener('mouseleave', (event) => unHoverPost(event, link));
  405. });
  406.  
  407. postLinks.forEach(link => addHoverPost(link));
  408. }
  409. };
  410.  
  411. window.customElements.define('fullchan-x', fullChanX);
  412.  
  413.  
  414. class fullChanXGallery extends HTMLElement {
  415. constructor() {
  416. super();
  417. }
  418.  
  419. init() {
  420. this.fullchanX = document.querySelector('fullchan-x');
  421. this.imageContainer = this.querySelector('.gallery__images');
  422. this.mainImageContainer = this.querySelector('.gallery__main-image');
  423. this.mainImage = this.mainImageContainer.querySelector('img');
  424. this.closeButton = this.querySelector('.gallery__close');
  425. this.listeners();
  426. this.addGalleryImages();
  427. this.initalized = true;
  428. }
  429.  
  430. addGalleryImages () {
  431. this.thumbs = [...this.fullchanX.threadParent.querySelectorAll('.imgLink')].map(thumb => {
  432. return thumb.cloneNode(true);
  433. });
  434.  
  435. this.thumbs.forEach(thumb => {
  436. this.imageContainer.appendChild(thumb);
  437. });
  438. }
  439.  
  440. updateGalleryImages () {
  441. if (!this.initalized) return;
  442.  
  443. const newThumbs = [...this.fullchanX.threadParent.querySelectorAll('.imgLink')].filter(thumb => {
  444. return !this.thumbs.find(thisThumb.href === thumb.href);
  445. }).map(thumb => {
  446. return thumb.cloneNode(true);
  447. });
  448.  
  449. newThumbs.forEach(thumb => {
  450. this.thumbs.push(thumb);
  451. this.imageContainer.appendChild(thumb);
  452. });
  453. }
  454.  
  455. listeners () {
  456. this.addEventListener('click', event => {
  457. const clicked = event.target;
  458.  
  459. let imgLink = clicked.closest('.imgLink');
  460. if (imgLink?.dataset.filemime === 'video/webm') return;
  461.  
  462. if (imgLink) {
  463. event.preventDefault();
  464. this.mainImage.src = imgLink.href;
  465. }
  466.  
  467.  
  468. this.mainImageContainer.classList.toggle('active', !!imgLink);
  469.  
  470. if (clicked.closest('.gallery__close')) this.close();
  471. });
  472. }
  473.  
  474. open () {
  475. if (!this.initalized) this.init();
  476. this.classList.add('open');
  477. document.body.classList.add('fct-gallery-open');
  478. }
  479.  
  480. close () {
  481. this.classList.remove('open');
  482. document.body.classList.remove('fct-gallery-open');
  483. }
  484. }
  485.  
  486. window.customElements.define('fullchan-x-gallery', fullChanXGallery);
  487.  
  488.  
  489.  
  490. class fullChanXSettings extends HTMLElement {
  491. constructor() {
  492. super();
  493. this.settingsKey = 'fullchan-x-settings';
  494. this.inputs = [];
  495. this.settings = {};
  496. this.settingsTemplate = {
  497. enableNestedQuotes: {
  498. info: 'Nest posts when clicking backlinks.',
  499. type: 'checkbox',
  500. value: true
  501. },
  502. enableFileExtentions: {
  503. info: 'Always show filetype on shortened file names.',
  504. type: 'checkbox',
  505. value: true
  506. },
  507. customBoardLinks: {
  508. info: 'List of custom boards in nav (seperate by comma)',
  509. type: 'input',
  510. value: 'v,a,b'
  511. },
  512. hideDefaultBoards: {
  513. info: 'List of boards to remove from nav (seperate by comma). Set as "all" to remove all.',
  514. type: 'input',
  515. value: 'interracial,mlp'
  516. },
  517. catalogBoardLinks: {
  518. info: 'Redirect nav board links to catalog pages.',
  519. type: 'checkbox',
  520. value: true
  521. },
  522. uiTopPosition: {
  523. info: 'Position from top of screen e.g. 100px',
  524. type: 'input',
  525. value: '50px'
  526. },
  527. uiRightPosition: {
  528. info: 'Position from right of screen e.g. 100px',
  529. type: 'input',
  530. value: '25px'
  531. },
  532. uiDimWhenInactive: {
  533. info: 'Dim UI when not hovering with mouse.',
  534. type: 'checkbox',
  535. value: true
  536. },
  537. replyTabIcon: {
  538. info: 'Set the icon/text added to tab title when you get a new (You).',
  539. type: 'input',
  540. value: '❗'
  541. },
  542. };
  543. }
  544.  
  545. init() {
  546. this.settingsContainer = this.querySelector('.fcx-settings__settings');
  547. this.getSavedSettings();
  548. this.buildSettingsOptions();
  549. this.listeners();
  550. this.querySelector('.fcx-settings__close').addEventListener('click', () => this.close());
  551. }
  552.  
  553. setSavedSettings (updated) {
  554. localStorage.setItem(this.settingsKey, JSON.stringify(this.settings));
  555. if (updated) this.classList.add('fcxs-updated');
  556. }
  557.  
  558. getSavedSettings() {
  559. const saved = JSON.parse(localStorage.getItem(this.settingsKey));
  560. if (saved) this.settings = saved;
  561. }
  562.  
  563. listeners() {
  564. this.inputs.forEach(input => {
  565. input.addEventListener('change', () => {
  566. const key = input.name;
  567. const value = input.type === 'checkbox' ? input.checked : input.value;
  568. this.settings[key].value = value;
  569. this.setSavedSettings(true);
  570. });
  571. });
  572. }
  573.  
  574. buildSettingsOptions() {
  575. Object.entries(this.settingsTemplate).forEach(([key, config]) => {
  576. const wrapper = document.createElement('div');
  577. const infoWrapper = document.createElement('div');
  578. wrapper.classList.add('fcx-setting');
  579. infoWrapper.classList.add('fcx-setting__info');
  580. wrapper.appendChild(infoWrapper);
  581.  
  582. const label = document.createElement('label');
  583. label.textContent = key
  584. .replace(/([A-Z])/g, ' $1')
  585. .replace(/^./, str => str.toUpperCase());
  586. label.setAttribute('for', key);
  587. infoWrapper.appendChild(label);
  588.  
  589. if (config.info) {
  590. const info = document.createElement('p');
  591. info.textContent = config.info;
  592. infoWrapper.appendChild(info);
  593. }
  594.  
  595. const savedValue = this.settings[key]?.value ?? config.value;
  596.  
  597. let input;
  598.  
  599. if (config.type === 'checkbox') {
  600. input = document.createElement('input');
  601. input.type = 'checkbox';
  602. input.checked = savedValue;
  603. } else if (config.type === 'input') {
  604. input = document.createElement('input');
  605. input.type = 'text';
  606. input.value = savedValue;
  607. } else if (config.type === 'select') {
  608. input = document.createElement('select');
  609. const options = config.options.split(',');
  610. options.forEach(opt => {
  611. const option = document.createElement('option');
  612. option.value = opt;
  613. option.textContent = opt;
  614. if (opt === savedValue) option.selected = true;
  615. input.appendChild(option);
  616. });
  617. }
  618.  
  619. if (input) {
  620. input.id = key;
  621. input.name = key;
  622. wrapper.appendChild(input);
  623. this.inputs.push(input);
  624. this.settings[key] = { value: input.type === 'checkbox' ? input.checked : input.value };
  625. }
  626.  
  627. this.settingsContainer.appendChild(wrapper);
  628. });
  629.  
  630. this.setSavedSettings();
  631. }
  632.  
  633. open() {
  634. this.classList.add('open');
  635. }
  636.  
  637. close() {
  638. this.classList.remove('open');
  639. }
  640.  
  641. toggle() {
  642. this.classList.toggle('open');
  643. }
  644. }
  645.  
  646. window.customElements.define('fullchan-x-settings', fullChanXSettings);
  647.  
  648.  
  649.  
  650. // Create fullchan-x settings
  651. const fcxs = document.createElement('fullchan-x-settings');
  652. fcxs.innerHTML = `
  653. <div class="fcxs fcx-settings">
  654. <header>
  655. <span class="fcx-settings__title">
  656. Fullchan-X Settings
  657. </span>
  658. <button class="fcx-settings__close fullchan-x__option">Close</button>
  659. </header>
  660.  
  661. <main>
  662. <div class="fcxs__updated-message">
  663. <p>Settings updated, refresh page to apply</p>
  664. <button class="fullchan-x__option" onClick="location.reload()">Reload page</button>
  665. </div>
  666. <div class="fcx-settings__settings"></div>
  667. </main>
  668.  
  669. <footer>
  670. </footer>
  671. </div>
  672. `;
  673. document.body.appendChild(fcxs);
  674. fcxs.init();
  675.  
  676.  
  677. // Create fullchan-x gallery
  678. const fcxg = document.createElement('fullchan-x-gallery');
  679. fcxg.innerHTML = `
  680. <div class="gallery">
  681. <button id="#fcxg-close" class="gallery__close fullchan-x__option">Close</button>
  682. <div id="#fcxg-images" class="gallery__images"></div>
  683. <div id="#fcxg-main-image" class="gallery__main-image">
  684. <img src="" />
  685. </div>
  686. </div>
  687. `;
  688. document.body.appendChild(fcxg);
  689.  
  690.  
  691.  
  692. // Create fullchan-x element
  693. const fcx = document.createElement('fullchan-x');
  694. fcx.innerHTML = `
  695. <div class="fcx__controls">
  696. <button id="fcx-settings-btn" class="fullchan-x__option fcx-settings-toggle">
  697. ⚙️<span>Settings</span>
  698. </button>
  699.  
  700. <div class="fullchan-x__option thread-only">
  701. <select id="thread-sort">
  702. <option value="default">Default</option>
  703. <option value="replies">Replies</option>
  704. <option value="catbox">Catbox</option>
  705. </select>
  706. </div>
  707.  
  708. <button id="fcx-gallery-btn" class="gallery__toggle fullchan-x__option thread-only">
  709. 🖼️<span>Gallery</span>
  710. </button>
  711.  
  712. <div class="fcx__my-yous thread-only">
  713. <p class="my-yous__label fullchan-x__option">💬<span>My (You)s</span></p>
  714. <div class="my-yous__yous" id="my-yous"></div>
  715. </div>
  716. </div>
  717. `;
  718. document.body.appendChild(fcx);
  719. fcx.styleUI()
  720. onload = (event) => fcx.init();
  721.  
  722.  
  723. // Styles
  724. const style = document.createElement('style');
  725. style.innerHTML = `
  726. fullchan-x {
  727. --top: 50px;
  728. --right: 25px;
  729. top: var(--top);
  730. right: var(--right);
  731. display: block;
  732. position: fixed;
  733. padding: 10px;
  734. background: var(--background-color);
  735. border: 1px solid var(--navbar-text-color);
  736. color: var(--link-color);
  737. font-size: 14px;
  738. z-index: 1000;
  739. }
  740.  
  741. fullchan-x:not(.page-thread) .thread-only,
  742. fullchan-x:not(.page-catalog) .catalog-only{
  743. display: none!important;
  744. }
  745.  
  746. fullchan-x:not(:hover):not(:has(select:focus)) {
  747. z-index: 3;
  748. }
  749.  
  750. fullchan-x.fcx--dim:not(:hover) {
  751. opacity: 0.6;
  752. }
  753.  
  754. .divPosts {
  755. flex-direction: column;
  756. }
  757.  
  758. .fcx__controls {
  759. display: flex;
  760. flex-direction: column;
  761. gap: 6px;
  762. }
  763.  
  764. fullchan-x:not(:hover):not(:has(select:focus)) span,
  765. fullchan-x:not(:hover):not(:has(select:focus)) select {
  766. display: none;
  767. margin-left: 5px;
  768. z-index:3;
  769. }
  770.  
  771. .fcx__controls span,
  772. .fcx__controls select {
  773. margin-left: 5px;
  774. }
  775.  
  776. #thread-sort {
  777. border: none;
  778. background: none;
  779. }
  780.  
  781. .my-yous__yous {
  782. display: none;
  783. flex-direction: column;
  784. padding-top: 10px;
  785. max-height: calc(100vh - 220px - var(--top));
  786. overflow: auto;
  787. }
  788.  
  789. .fcx__my-yous:hover .my-yous__yous {
  790. display: flex;
  791. }
  792.  
  793. .fullchan-x__option {
  794. display: flex;
  795. padding: 6px 8px;
  796. background: white;
  797. border: none !important;
  798. border-radius: 0.2rem;
  799. transition: all ease 150ms;
  800. cursor: pointer;
  801. margin: 0;
  802. text-align: left;
  803. min-width: 18px;
  804. min-height: 18px;
  805. align-items: center;
  806. }
  807.  
  808. .fullchan-x__option,
  809. .fullchan-x__option select {
  810. font-size: 12px;
  811. font-weight: 400;
  812. color: #374369;
  813. }
  814.  
  815. fullchan-x:not(:hover):not(:has(select:focus)) .fullchan-x__option {
  816. display: flex;
  817. justify-content: center;
  818. }
  819.  
  820. #thread-sort {
  821. padding-right: 0;
  822. }
  823.  
  824. #thread-sort:hover {
  825. display: block;
  826. }
  827.  
  828. .innerPost:has(.quoteLink.you) {
  829. border-left: solid #dd003e 6px;
  830. }
  831.  
  832. .innerPost:has(.youName) {
  833. border-left: solid #68b723 6px;
  834. }
  835.  
  836. /* --- Nested quotes --- */
  837. .divMessage .nestedPost {
  838. display: inline-block;
  839. width: 100%;
  840. margin-bottom: 14px;
  841. white-space: normal!important;
  842. overflow-wrap: anywhere;
  843. margin-top: 0.5em;
  844. border: 1px solid var(--navbar-text-color);
  845. }
  846.  
  847. .nestedPost .innerPost,
  848. .nestedPost .innerOP {
  849. width: 100%;
  850. }
  851.  
  852. .nestedPost .imgLink .imgExpanded {
  853. width: auto!important;
  854. height: auto!important;
  855. }
  856.  
  857. .my-yous__label.unseen {
  858. background: var(--link-hover-color);
  859. color: white;
  860. }
  861.  
  862. .my-yous__yous .unseen {
  863. font-weight: 900;
  864. color: var(--link-hover-color);
  865. }
  866.  
  867.  
  868.  
  869. /*--- Settings --- */
  870. .fcx-settings {
  871. display: block;
  872. position: fixed;
  873. top: 50vh;
  874. left: 50vw;
  875. translate: -50% -50%;
  876. padding: 20px 0;
  877. background: var(--background-color);
  878. border: 1px solid var(--navbar-text-color);
  879. color: var(--link-color);
  880. font-size: 14px;
  881. max-width: 480px;
  882. max-height: 80vh;
  883. overflow: scroll;
  884. }
  885.  
  886. fullchan-x-settings:not(.open) {
  887. display: none;
  888. }
  889.  
  890. .fcx-settings > * {
  891. padding: 0 20px;
  892. }
  893.  
  894. .fcx-settings header {
  895. display: flex;
  896. align-items: center;
  897. justify-content: space-between;
  898. margin: 0 0 15px;
  899. padding-bottom: 20px;
  900. border-bottom: 1px solid var(--navbar-text-color);
  901. }
  902.  
  903. .fcx-settings__title {
  904. font-size: 24px;
  905. font-size: 24px;
  906. letter-spacing: 0.04em;
  907. }
  908.  
  909. fullchan-x-settings:not(.fcxs-updated) .fcxs__updated-message {
  910. display: none;
  911. }
  912.  
  913. .fcx-setting {
  914. display: flex;
  915. justify-content: space-between;
  916. align-items: center;
  917. padding: 12px 0;
  918. }
  919.  
  920. .fcx-setting__info {
  921. max-width: 60%;
  922. }
  923.  
  924. .fcx-setting input[type="text"],
  925. .fcx-setting select {
  926. padding: 4px 6px;
  927. min-width: 35%;
  928. }
  929.  
  930. .fcx-setting label {
  931. font-weight: 600;
  932. }
  933.  
  934. .fcx-setting p {
  935. margin: 6px 0 0;
  936. font-size: 12px;
  937. }
  938.  
  939. .fcx-setting + .fcx-setting {
  940. border-top: 1px solid var(--navbar-text-color);
  941. }
  942.  
  943. .fcxs__updated-message {
  944. margin: 10px 0;
  945. text-align: center;
  946. }
  947.  
  948. .fcxs__updated-message p {
  949. font-size: 14px;
  950. color: var(--error);
  951. }
  952.  
  953. .fcxs__updated-message button {
  954. margin: 14px auto 0;
  955. }
  956.  
  957. /* --- Gallery --- */
  958. .fct-gallery-open,
  959. body.fct-gallery-open,
  960. body.fct-gallery-open #mainPanel {
  961. overflow: hidden!important;
  962. }
  963.  
  964. body.fct-gallery-open fullchan-x {
  965. display: none;
  966. }
  967.  
  968. fullchan-x-gallery {
  969. position: fixed;
  970. top: 0;
  971. left: 0;
  972. width: 100%;
  973. background: rgba(0,0,0,0.9);
  974. display: none;
  975. height: 100%;
  976. overflow: auto;
  977. }
  978.  
  979. fullchan-x-gallery.open {
  980. display: block;
  981. }
  982.  
  983. fullchan-x-gallery .gallery {
  984. padding: 50px 10px 0
  985. }
  986.  
  987. fullchan-x-gallery .gallery__images {
  988. display: flex;
  989. width: 100%;
  990. height: 100%;
  991. justify-content: center;
  992. align-content: flex-start;
  993. gap: 4px 8px;
  994. flex-wrap: wrap;
  995. }
  996.  
  997. fullchan-x-gallery .imgLink img {
  998. border: solid white 1px;
  999. }
  1000.  
  1001. fullchan-x-gallery .imgLink[data-filemime="video/webm"] img {
  1002. border: solid #68b723 4px;
  1003. }
  1004.  
  1005. fullchan-x-gallery .gallery__close {
  1006. position: fixed;
  1007. top: 60px;
  1008. right: 35px;
  1009. padding: 6px 14px;
  1010. min-height: 30px;
  1011. z-index: 10;
  1012. }
  1013.  
  1014. .gallery__main-image {
  1015. display: none;
  1016. position: fixed;
  1017. top: 0;
  1018. left: 0;
  1019. width: 100%;
  1020. height: 100%;
  1021. justify-content: center;
  1022. align-content: center;
  1023. background: rgba(0,0,0,0.5);
  1024. }
  1025.  
  1026. .gallery__main-image img {
  1027. padding: 40px 10px 15px;
  1028. height: auto;
  1029. max-width: calc(100% - 20px);
  1030. object-fit: contain;
  1031. }
  1032.  
  1033. .gallery__main-image.active {
  1034. display: flex;
  1035. }
  1036.  
  1037. /*-- Truncated file extentions --*/
  1038. .originalNameLink[data-file-ext] {
  1039. max-width: 65px;
  1040. }
  1041.  
  1042. a[data-file-ext]:hover:after {
  1043. content: attr(data-file-ext);
  1044. }
  1045.  
  1046. a[data-file-ext] + .file-ext {
  1047. pointer-events: none;
  1048. }
  1049.  
  1050. a[data-file-ext]:hover + .file-ext {
  1051. display: none;
  1052. }
  1053.  
  1054. /*-- Nav Board Links --*/
  1055. .nav-boards--custom {
  1056. display: flex;
  1057. gap: 3px;
  1058. }
  1059.  
  1060. #navTopBoardsSpan.hidden ~ #navBoardsSpan,
  1061. #navTopBoardsSpan.hidden ~ .nav-fade,
  1062. #navTopBoardsSpan a.hidden + span {
  1063. display: none;
  1064. }
  1065. `;
  1066.  
  1067. document.head.appendChild(style);
  1068.  
  1069.  
  1070. // Asuka and Eris (fantasy Asuka) are best girls