arcaliveDualMode2

아카라이브 심야식당 게시글 목록을 둘로나눠, 좌우에 각각 보여줍니다.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         arcaliveDualMode2
// @namespace    http://tampermonkey.net/
// @version      0.46
// @description  아카라이브 심야식당 게시글 목록을 둘로나눠, 좌우에 각각 보여줍니다.
// @author       Jayscript
// @match        https://arca.live/b/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=arca.live
// @grant        none
// @license      MIT
// ==/UserScript==
"use strict";

let originalMediaWidth = getOriginalMediaWidth2();
const originalContentWrapper = getContentWrapperCloned();
let changedContentWrapper;

let timer = null;


function arcaliveDualMode()
{
    if (window.innerWidth >100)
    {
        removeRightSidebar();
        extendContentWrapper();
        moveArticlesToRightPlane();
        restoreMediaSize2();
        changedContentWrapper = getContentWrapper();
        changedContentWrapper.after(originalContentWrapper);
        setDisplayOptionAsWidthSize();
    }

    addEventListener('resize', function() {	clearTimeout(timer); timer = setTimeout(setDisplayOptionAsWidthSize, 300); console.log('event');} );
}

function setDisplayOptionAsWidthSize()
{
    if (window.innerWidth > 1800)
    {
        originalContentWrapper.style.display = 'none';
        originalContentWrapper.querySelector('.right-sidebar').style.display ='none';
        changedContentWrapper.style.display = 'block';
        changedContentWrapper.querySelector('.right-sidebar').style.display ='none';
    }
    else
    {
        originalContentWrapper.style.display = 'block';
        let originalSidebar=originalContentWrapper.querySelector('.right-sidebar');
        originalSidebar.style.display='block';
        for (const el of originalSidebar.children){
            el.style.display='block';
        }
        // TODO: Display Sidebar As small size.
        changedContentWrapper.style.display = 'none';
        changedContentWrapper.querySelector('.right-sidebar').style.display ='none';
    }
}

function getOriginalMediaWidth() {
    let image=document.querySelector('.fr-view.article-content img');
    let video=document.querySelector('.fr-view.article-content video');
    let width =null;
    if (image){
        width = image.offsetWidth;
    }
    if (video){
        width = video.offsetWidth;
    }
    return width;
};
function getOriginalMediaWidth2() {
    let images=document.querySelectorAll('.fr-view.article-content img');
    let videos=document.querySelectorAll('.fr-view.article-content video');
    let widths = {'image':[],'video':[]};
    if (images){
        images.forEach((el)=>widths.image.push(el.offsetWidth));
    }
    if (videos){
        videos.forEach((el)=>widths.video.push(el.offsetWidth));
    }
    return widths;
};


function getContentWrapperCloned() {
    return getContentWrapper().cloneNode(true);
}
function getContentWrapper() {
    return document.querySelector('.content-wrapper.clearfix');
}

function removeRightSidebar()
{
    document.querySelector('.right-sidebar').style.display = 'none';
}

function extendContentWrapper()
{
    const contentWrapper = document.querySelector('.content-wrapper.clearfix');
    contentWrapper.style='margin:0 5rem 0;max-width:100%';
    const containerBoard = document.querySelector('.containe-fluid.board-article');
    containerBoard.style='margin:0';
}
function moveArticlesToRightPlane()
{
    cloneArticleListAndArrangeIt();
    moveHalfToRightPlane();
}

function cloneArticleListAndArrangeIt()
{
    let articleList = document.querySelector('.article-list');
    let articleList2 = articleList.cloneNode(true);
    articleList.after(articleList2);

    articleList.style='margin:5 0rem 0 0;float:left;width:49%;';
    articleList2.style='margin:5 0rem 0 0;float:right;width:49%;';

    articleList2.querySelector('.list-table').childNodes.forEach( el => el.tagName=='A' && el.remove() );
}
function moveHalfToRightPlane()
{
    let articleList = document.querySelector('.article-list');
    let articleList2 = document.querySelectorAll('.article-list')[1];
    let articleTable2 = articleList2.querySelector('.list-table');

    let articles=articleList.querySelectorAll('a.vrow:not(.notice)');
    let articles2=articleList2.querySelectorAll('a.vrow:not(.notice)');
    let noticesInArticles2=articleList2.querySelectorAll('a.vrow.notice');

    articles.forEach((el, i) => i>=articles.length/2 && articleTable2.append(el));
}

function restoreMediaSize()
{
    let images = document.querySelectorAll('.fr-view.article-content img');
    let videos = document.querySelectorAll('.fr-view.article-content video');
    images.forEach(function (el) { el.style.width = `${originalMediaWidth}px`;});
    videos.forEach(function (el) { el.style.width = `${originalMediaWidth}px`;});
    console.log(originalMediaWidth);
}
function restoreMediaSize2()
{
    let images = document.querySelectorAll('.fr-view.article-content img');
    let videos = document.querySelectorAll('.fr-view.article-content video');
    images.forEach(function (el, i) { el.style.width = `${originalMediaWidth.image[i]}px`;});
    videos.forEach(function (el, i) { el.style.width = `${originalMediaWidth.video[i]}px`;});
}

addEventListener('load',setTimeout(arcaliveDualMode,0));