Youtube Reintegration

Make sure to hit that subscribe button!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Youtube Reintegration
// @icon         https://pixelplace.io/img/youtube-icon.svg
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Make sure to hit that subscribe button!
// @author       guildedbird
// @match        https://pixelplace.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function add() {
        let linked = document.querySelectorAll('#modals .box > .box-content[data-id=account]');
        linked.forEach(account => {
            let firstChild = account.firstElementChild;
            if (firstChild) {
                let div = document.createElement('div');
                div.className = 'linked-account';
                div.setAttribute('data-id', '4');
                div.innerHTML = `
                    <div data-value="youtube">
                        <img src="/img/youtube-icon.svg" width="24">
                    </div>
                    <span></span>
                    <a href="https://pixelplace.io/api/sso.php?type=4&amp;action=remove" title="Disconnect Youtube account?" class="link-remove">Disconnect?</a>
                    <a href="https://pixelplace.io/api/sso.php?type=4&amp;action=login" title="Connect your Youtubw account" class="link-add" style="display: none;">Connect your Youtube account</a>
                `;
                let children = firstChild.children;
                if (children.length >= 4) {
                    firstChild.insertBefore(div, children[4]);
                } else {
                    firstChild.appendChild(div);
                }
            }
        });
    }

    function style() {
        let youtube = document.querySelector('#modals .box > .box-content div .margin-bottom a.sso[data-value="youtube"]');
        if (youtube) {
            youtube.style = 'block';
        }
    }

    window.addEventListener('load', () => {
        add();
        style();
    });

    const image = 'https://support.discord.com/hc/user_images/PRywUXcqg0v5DD6s7C3LyQ.jpeg';

    function replace() {
        document.querySelectorAll('img[src*="discordapp-tile.svg"]').forEach(img => {
            img.src = image;
            img.style.borderRadius = '7px';
        });
    }

    replace();

    const observer = new MutationObserver(replace);
    observer.observe(document.body, { childList: true, subtree: true });
})();