Copy F-List Channels

Take the list of saved channels from one character and paste them on another

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Copy F-List Channels
// @namespace    http://f-list.net/c/Dik
// @version      1.0
// @description  Take the list of saved channels from one character and paste them on another
// @author       Futah AKA Dik
// @match        https://www.f-list.net/c/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=f-list.net
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', () => {

        // Badges Element that will contain the buttons
        const badges = document.querySelector('#charabadges');

        // Create new buttons
        for (let btnName of ['Copy', 'Paste']) {
            let button = document.createElement('span');
            button.className = 'Character_StatusCoder';
            button.textContent = btnName + ' Channels';

            // Hover Style
            button.addEventListener('mouseenter', () => {
                button.style.textDecoration = 'underline';
                button.style.cursor = 'pointer';
            });
            button.addEventListener('mouseleave', () => {
                button.style.textDecoration = '';
                button.style.cursor = '';
            });

            // Click Handling
            button.addEventListener('click', () => {
                const name = document.querySelector('span.charname').innerText;

                const charChannels = localStorage.getItem(name + '.settings.recentChannels');
                const charPins = localStorage.getItem(name + '.settings.pinned');

                const clipboardChannels = localStorage.getItem('ccClipboard.channels');
                const clipboardPins = localStorage.getItem('ccClipboard.pins');

                if (btnName == 'Copy') {
                    if (charChannels == null) {
                        alert('This character does not have any channels saved,\nor does not belong to you.');
                    }
                    else {
                        localStorage.setItem('ccClipboard.channels', charChannels);
                        localStorage.setItem('ccClipboard.pins', charPins);
                        alert('Channel settings copied!');
                    }
                }
                if (btnName == 'Paste') {
                    localStorage.setItem(name + '.settings.recentChannels', clipboardChannels);

                    let charPinsParsed = JSON.parse(charPins);
                    let clipboardPinsParsed = JSON.parse(clipboardPins);

                    charPinsParsed.channels = clipboardPinsParsed.channels;
                    localStorage.setItem(name + '.settings.pinned', JSON.stringify(charPinsParsed));

                    alert('Channel settings imported!\nYou might need to refresh the chat page to see the changes.');
                }
            });

            // Add Button
            badges.appendChild(button);
        }

    });
})();