GithubHelp home page GithubHelp logo

rocket.chat-avatar's Introduction

/** 로켓챗에 아바타 추가 방법

  1. 로켓챗에 접속한다.
  2. 관리자 계정으로 로그인한다.
  3. 관리메뉴를 클릭한다.
  4. 메뉴 중 레이아웃을 클릭한다.
  5. 사용자 정의 스크립트를 펼친다.
  6. 로그인한 사용자를 위한 사용자 정의 스크립트에 아래 내용을 붙혀넣는다.
  7. 저장한다.
  8. 변화가있느지 확인한다. **/
let eventCode = null;
let pathname = null;
function avatarOpen() {
    try {
        if (pathname === location.pathname ) {

        } else if( $("div[name=avatar]").length > 0 ) {
            $("div[name=avatar]").remove();
        } else {
            clearTimeout(eventCode);
            token = localStorage.getItem("Meteor.loginToken")
            uid = localStorage.getItem("Meteor.userId")
            fetch("/api/v1/users.info?userId=" + uid, {
                method: "GET",
                headers: {
                    "X-Auth-Token": token,
                    "X-User-Id": uid,
                    "Content-Type": "application/json"
                }
            })
                .then(res => res.json())
                .then(json => {
                    const user = json.user;
                    console.log(user);
                    pathname = location.pathname;
                    const roomKey = location.pathname;
                    const roomName = $("main div:eq(2) div:eq(2)").text() + " 대화방 입장";
                    $("div[name=avatar]").remove();
                    $(".messages-box:eq(0)").before(`
                        <div name="avatar" style="border-bottom: 1px solid silver; width: 100%; height: 550px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
                            <iframe allow="microphone" src="https://avatar.danawa.io?userName=${user.username||user.name}&roomKey=${roomKey}&roomName=${roomName}" style="width: 100%; height: 100%;"></iframe>
                        </div>
                    `)
                    eventCode = setTimeout(() => avatarOpen(), 500)
                })
        }
    } catch(err) {
        console.log(err)
    }
    if (eventCode !== null) {
        clearTimeout(eventCode);
        eventCode = null
    }
    eventCode = setTimeout(() => avatarOpen(), 500)
}
eventCode = setTimeout(() => avatarOpen(), 500)

rocket.chat-avatar's People

Contributors

joonwoo8888 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.