ChelonianGall

Integrate the ChelonianGall webchat in CodinGame.

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        ChelonianGall
// @namespace   cheloniangall.com
// @match       https://www.codingame.com/*
// @grant       none
// @version     1.1
// @icon        https://cheloniangall.com/images/icon.png
// @supportURL  https://cheloniangall.com/faq.php
// @author      BlaiseEbuth
// @description Integrate the ChelonianGall webchat in CodinGame.
// @license     MIT
// ==/UserScript==

"use strict";

var chatReady = false;

setInterval(

  function() {

    if (!chatReady) {

      var head = document.getElementsByTagName("head")[0];
      var columns = document.getElementsByClassName("column-contents")[0];
      var leftColumn = document.getElementById("scrollable-pane");

      if (head && columns && leftColumn) {

        columns.style = "\
          display: flex;\
          flex-direction: row;\
          justify-content: space-between;";

        leftColumn.style = "\
          width: auto;\
          position: static;\
          order: 0;\
          flex-grow: 2;";

        var chatStyle = document.createElement("style");
        var chatContainer = document.createElement("div");
        var chatToggle = document.createElement("div");
        var chat = document.createElement("iframe");

        chatStyle.textContent = "\
          #cg-chat-container {\
            order: 1;\
            display: flex;\
            flex-direction: row;\
            width: fit-content;\
            height: 100%;\
          }\
          #cg-chat {\
            min-width: 301px;\
            height: 100%;\
            border: none\
          }\
          #cg-chat.hidden {\
            display: none;\
          }\
          #cg-chat-toggle {\
            display: flex;\
            flex-direction: column;\
            justify-content: center;\
            width: fit-content;\
            height: 100%;\
            background-color: rgb(54, 62, 72);\
            font-size: 20px;\
            font-weight: bold;\
            color: rgb(242, 187, 19);\
            cursor: pointer;\
          }\
          #cg-chat-toggle:hover {\
            background-color: rgb(242, 187, 19);\
            color: rgb(54, 62, 72);\
          }\
          #cg-chat-toggle.open {\
            right: 301px;\
          }\
          #cg-chat-toggle::before {\
            display: block;\
            margin: 0 2px 0 5px;\
            content: '<';\
          }\
          #cg-chat-toggle.open::before {\
            content: '>';\
          }\
        ";

        chatContainer.id = "cg-chat-container";

        chatToggle.id = "cg-chat-toggle";
        chatToggle.classList.add("open");
        chatToggle.onclick = function ()
        {
          document.getElementById("cg-chat").classList.toggle("hidden");
          document.getElementById("cg-chat-toggle").classList.toggle("open");
        };

        chat.id = "cg-chat";
        chat.title = "ChelonianGall webchat";
        chat.src = "https://cheloniangall.com";

        head.appendChild(chatStyle);
        columns.appendChild(chatContainer);
        chatContainer.appendChild(chatToggle);
        chatContainer.appendChild(chat);

        chatReady = true;
      }
    }
  },
  100
);