RocketChat / feature-requests

This repository is used to track Rocket.Chat feature requests and discussions. Click here to open a new feature request.
21 stars 9 forks source link

Google Meet support #65

Open jhmk opened 5 years ago

jhmk commented 5 years ago

Normally RC is just supporting Jitsi & BigBlueButton for Video Conference. By changing the Domain in the settings for Jitsi to "hangouts.google.com/hangouts/_" you can use hangouts at the moment because a new Meeting will be created when opening this URL.

But because Hangouts will be deactivated this year and the new Google Meet don't support auto-creating a meeting URL by opening an URL this will stop working.

So it needs to push a request to generate a meeting. Docs: https://developers.google.com/calendar/create-events

The request Body would look like this: { "summary": "test", "end": { "dateTime": "2019-03-27T13:00:00-07:00" }, "start": { "dateTime": "2019-03-27T11:00:00-07:00" }, "conferenceData": { "createRequest": { "conferenceSolutionKey": { "type": "hangoutsMeet" } } } }

nahid commented 2 years ago

Here is the code for version 4.7.0

/* ENTER - gMeetButton */
function addMeetButton() {
    // preconditions
    const headerButtons = $('header .rcx-button-group');
    // exit if headerButtons isn't visible
    if (!headerButtons.is(':visible')) {
        return;
    }

    // exit if button is present already
    if ($(`.rcx-button-group__item[data-id="meet"]`).is(':visible')) {
        return;
    }

    /* local functions */
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function uuidv4() {
        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }

    /* Google Meet SVG */
    const meetButtonSymbol = `
<svg id="icon-meet" viewBox="0 0 468 468" fill="currentColor">
  <path d="M 238.5,421.7502 V 387.5 l -10.80713,-0.6693 C 190.25427,384.5122 154.14002,371.1781 123.02577,348.1858 113.90356,341.4448 96.855431,325.0588 89.019172,315.5 76.281547,299.9624 64.156705,277.9322 58.087931,259.2995 33.715022,184.46833 66.347377,98.13147 136.21304,52.6004 180.89993,23.47821 236.61288,15.06651 289.45785,29.46307 c 66.89494,18.22419 119.73348,75.21313 133.59773,144.09166 2.76051,13.71437 3.78323,43.62827 1.99037,58.21657 -9.18324,74.7226 -63.02462,149.0915 -145.99323,201.6545 -12.70446,8.0486 -38.24275,22.574 -39.68991,22.5744 -0.47455,2e-4 -0.86281,-15.4123 -0.86281,-34.25 z m 50.94617,-140.0311 c 6.6072,-2.9819 10.26549,-6.4304 13.21334,-12.4556 2.69603,-5.5105 2.83071,-6.486 3.19379,-23.1345 l 0.37906,-17.3815 24.38382,24.3686 L 355,277.4847 V 208.5 139.51531 l -24.41499,24.39973 -24.41499,24.39974 -0.33958,-17.40739 c -0.37876,-19.41617 -1.40213,-23.32523 -7.77471,-29.69781 -7.12934,-7.12934 -2.09969,-6.67875 -78.05573,-6.99283 -77.15948,-0.31905 -73.63703,-0.63235 -81.5202,7.25082 -7.54646,7.54646 -7.4798,6.95352 -7.4798,66.52903 0,58.4869 0.071,59.2215 6.44445,66.6675 3.85086,4.4988 8.95106,7.3527 15.05555,8.4243 2.2,0.3862 33.025,0.6368 68.5,0.5569 59.52503,-0.1341 64.80437,-0.2827 68.44617,-1.9262 z"></path>
</svg>
`;

    /* Description-Text on Hover: Customize this for different languages */
    const meetButtonLabel = {
        'en': 'New Google Meet Room',
        'de': 'Öffne Google-Konferenz Raum',
        'fr': 'New Google Meet Room',
        'es': 'New Google Meet Room',
        'it': 'New Google Meet Room',
        'nl': 'New Google Meet Room',
        'pl': 'New Google Meet Room',
        'pt': 'New Google Meet Room',
        'ru': 'Смена оформления',
        'bn': 'নতুন গুগোল মিট রুম তৈরী করুন',
    }[defaultUserLanguage()] || 'New Google Meet Room';

    const meetButtonHtml = `
    <button type="button" class="rcx-box rcx-box--full rcx-box--animated rcx-button--tiny-square rcx-button--square rcx-button--ghost rcx-button  rcx-button-group__item rcx-css-15vvv6z" data-id="meet" data-toolbox="0" data-title="${meetButtonLabel}" data-tooltip="${meetButtonLabel}"><i aria-hidden="true" class="rcx-box rcx-box--full rcx-icon--name-info-circled rcx-icon rcx-css-4pvxx3"><svg class="rc-icon tab-button-icon tab-button-icon--meet" aria-hidden="true" viewBox="0 0 468 468">
                <use xlink:href="#icon-meet"></use>
                ${meetButtonSymbol}
            </svg></i></button>
    `;

    const meetButton = $(meetButtonHtml).prependTo(headerButtons);
    meetButton.on('click', async function () {
        var meetUri = "http://g.co/meet/r" + uuidv4();
        var chatInput = $('textarea[name="msg"]');
        if (chatInput.length == 1) {
            var keyboardEvent = {
                altKey: false,
                bubbles: true,
                cancelBubble: false,
                cancelable: true,
                charCode: 0,
                code: "Enter",
                composed: true,
                ctrlKey: false,
                currentTarget: document,
                defaultPrevented: false,
                detail: 0,
                eventPhase: 1,
                isComposing: false,
                isTrusted: true,
                key: "Enter",
                keyCode: 13,
                location: 0,
                metaKey: false,
                repeat: false,
                returnValue: true,
                shiftKey: false,
                srcElement: chatInput.get()[0],
                target: chatInput.get()[0],
                type: "keydown",
                which: 13
            };

            chatInput.get()[0].value = '*Please join[Meet]* \n' + meetUri;
            chatInput.change();
            chatInput.focus();
            chatInput.trigger(keyboardEvent);

            await sleep(500);
        }
        window.open(meetUri, '_blank');
    });
}

/* Interval to check if the icon is there; required for room/chat changes */
setInterval(addMeetButton, 250);
/* LEAVE - gMeetButton */

It looks like:

Screenshot 2022-05-30 at 2 08 50 PM

Vaarlion commented 2 years ago

hello :) Because of #26475 the link printed in the chat is broken. Sadly it look like simply replacing g.co by google.com or meet.google.com don't work, as i am landing on an invalid video call name error page.

What url should i go with ? https://meet.google.com/new don't take a name sadly

grthr commented 2 years ago

https://meet.google.com/lookup/foo-bar works

Vaarlion commented 2 years ago

It is working with that url thank you :)

Minor visual issue left, the icon at idle look like the hover version of it's neighbor, and get even darken when hovered. weirdly it doesn't look like the script do anything about CSS ... but it's really minor. image

anakinpendragon commented 1 year ago

Stop working in lasta 6.2.0 ...

deichbewohner commented 1 year ago

I use this for the latest version:

/* ENTER - gMeetButton */
function addMeetButton() {
    // preconditions
    const toolbar = $('.rcx-icon--name-discussion').parent().parent();
    // exit if toolbar isn't visible
    if (!toolbar.is(':visible')) {
        return;
    }

    // exit if toolbar isn't visible
    if ($(`button[data-id="meet"]`).is(':visible')) {
        return;
    }

    /* local functions */
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function uuidv4() {
        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }

    /* Google Meet SVG */
    const meetButtonSymbol = `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 87.5 72">
    <path fill="#00832d" d="M49.5 36l8.53 9.75 11.47 7.33 2-17.02-2-16.64-11.69 6.44z"/>
    <path fill="#0066da" d="M0 51.5V66c0 3.315 2.685 6 6 6h14.5l3-10.96-3-9.54-9.95-3z"/>
    <path fill="#e94235" d="M20.5 0L0 20.5l10.55 3 9.95-3 2.95-9.41z"/>
    <path fill="#2684fc" d="M20.5 20.5H0v31h20.5z"/>
    <path fill="#00ac47" d="M82.6 8.68L69.5 19.42v33.66l13.16 10.79c1.97 1.54 4.85.135 4.85-2.37V11c0-2.535-2.945-3.925-4.91-2.32zM49.5 36v15.5h-29V72h43c3.315 0 6-2.685 6-6V53.08z"/>
    <path fill="#ffba00" d="M63.5 0h-43v20.5h29V36l20-16.57V6c0-3.315-2.685-6-6-6z"/>
</svg>
`;

    /* Description-Text on Hover: Customize this for different languages */
    const meetButtonLabel = {
        'en': 'New Google Meet Room',
        'de': 'Öffne Google-Konferenz Raum',
        'fr': 'New Google Meet Room',
        'es': 'New Google Meet Room',
        'it': 'New Google Meet Room',
        'nl': 'New Google Meet Room',
        'pl': 'New Google Meet Room',
        'pt': 'New Google Meet Room'
    }[defaultUserLanguage()] || 'New Google Meet Room';

    const meetButtonHtml = `<button type="button" data-id="meet" class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button  rcx-button-group__item rcx-css-ll6zd0" data-toolbox="0" title="${meetButtonLabel}"><svg class="rc-icon" aria-hidden="true" viewBox="0 0 468 468"><use xlink:href="#icon-meet"></use>${meetButtonSymbol}</svg></button>`;

    const meetButton = $(meetButtonHtml).prependTo(toolbar);

    meetButton.on('click', async function () {
        var meetUri = "https://meet.google.com/lookup/r" + uuidv4();
        var chatInput = $('textarea[name="msg"]');
        if (chatInput.length == 1) {
            var keyboardEvent = {
                altKey: false,
                bubbles: true,
                cancelBubble: false,
                cancelable: true,
                charCode: 0,
                code: "Enter",
                composed: true,
                ctrlKey: false,
                currentTarget: document,
                defaultPrevented: false,
                detail: 0,
                eventPhase: 1,
                isComposing: false,
                isTrusted: true,
                key: "Enter",
                keyCode: 13,
                location: 0,
                metaKey: false,
                repeat: false,
                returnValue: true,
                shiftKey: false,
                srcElement: chatInput.get()[0],
                target: chatInput.get()[0],
                type: "keydown",
                which: 13
            };

            chatInput.get()[0].value = `:meet: ${meetUri}`;
            chatInput.change();
            chatInput.focus();
            // chatInput.trigger(keyboardEvent);

            await sleep(500);
        }
        //window.open(meetUri, '_blank');
    });
}

/* Interval to check if the icon is there; required for room/chat changes */
setInterval(addMeetButton, 500);
/* LEAVE - gMeetButton */
anakinpendragon commented 1 year ago

thank you, the button reappeared, but without the icon:

image

deichbewohner commented 1 year ago

Because it was just working for me i haven't even looked into the code. Currently the Icon is a svg in a svg. It works(for me) with only the inner svg. maybe that solves your problem. If not you could also insert something else instead of the svg, maybe a string "M". Here the new code:

/* ENTER - gMeetButton */
function addMeetButton() {
    // preconditions
    const toolbar = $('.rcx-icon--name-discussion').parent().parent();
    // exit if toolbar isn't visible
    if (!toolbar.is(':visible')) {
        return;
    }

    // exit if toolbar isn't visible
    if ($(`button[data-id="meet"]`).is(':visible')) {
        return;
    }

    /* local functions */
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function uuidv4() {
        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }

    /* Google Meet SVG */
    const meetButtonSymbol = `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 87.5 72">
    <path fill="#00832d" d="M49.5 36l8.53 9.75 11.47 7.33 2-17.02-2-16.64-11.69 6.44z"/>
    <path fill="#0066da" d="M0 51.5V66c0 3.315 2.685 6 6 6h14.5l3-10.96-3-9.54-9.95-3z"/>
    <path fill="#e94235" d="M20.5 0L0 20.5l10.55 3 9.95-3 2.95-9.41z"/>
    <path fill="#2684fc" d="M20.5 20.5H0v31h20.5z"/>
    <path fill="#00ac47" d="M82.6 8.68L69.5 19.42v33.66l13.16 10.79c1.97 1.54 4.85.135 4.85-2.37V11c0-2.535-2.945-3.925-4.91-2.32zM49.5 36v15.5h-29V72h43c3.315 0 6-2.685 6-6V53.08z"/>
    <path fill="#ffba00" d="M63.5 0h-43v20.5h29V36l20-16.57V6c0-3.315-2.685-6-6-6z"/>
</svg>
`;

    /* Description-Text on Hover: Customize this for different languages */
    const meetButtonLabel = {
        'en': 'New Google Meet Room',
        'de': 'Öffne Google-Konferenz Raum',
        'fr': 'New Google Meet Room',
        'es': 'New Google Meet Room',
        'it': 'New Google Meet Room',
        'nl': 'New Google Meet Room',
        'pl': 'New Google Meet Room',
        'pt': 'New Google Meet Room',
        'ru': 'Смена оформления'
    }[defaultUserLanguage()] || 'New Google Meet Room';

    const meetButtonHtml = `<button type="button" data-id="meet" class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button  rcx-button-group__item rcx-css-ll6zd0" data-toolbox="0" title="${meetButtonLabel}">${meetButtonSymbol}</button>`;

    const meetButton = $(meetButtonHtml).prependTo(toolbar);

    meetButton.on('click', async function () {
        var meetUri = "https://meet.google.com/lookup/r" + uuidv4();
        var chatInput = $('textarea[name="msg"]');
        if (chatInput.length == 1) {
            var keyboardEvent = {
                altKey: false,
                bubbles: true,
                cancelBubble: false,
                cancelable: true,
                charCode: 0,
                code: "Enter",
                composed: true,
                ctrlKey: false,
                currentTarget: document,
                defaultPrevented: false,
                detail: 0,
                eventPhase: 1,
                isComposing: false,
                isTrusted: true,
                key: "Enter",
                keyCode: 13,
                location: 0,
                metaKey: false,
                repeat: false,
                returnValue: true,
                shiftKey: false,
                srcElement: chatInput.get()[0],
                target: chatInput.get()[0],
                type: "keydown",
                which: 13
            };

            chatInput.get()[0].value = `:meet: ${meetUri}`;
            chatInput.change();
            chatInput.focus();
            // chatInput.trigger(keyboardEvent);

            await sleep(500);
        }
        //window.open(meetUri, '_blank');
    });
}

/* Interval to check if the icon is there; required for room/chat changes */
setInterval(addMeetButton, 500);
/* LEAVE - gMeetButton */
anakinpendragon commented 1 year ago

Thank you! deichbewohner You helped me a lot! I change from SVG to a utf simbol and worked fine.

`/ ENTER - gMeetButton / function addMeetButton() { // preconditions const toolbar = $('.rcx-icon--name-discussion').parent().parent(); // exit if toolbar isn't visible if (!toolbar.is(':visible')) { return; }

// exit if toolbar isn't visible
if ($(`button[data-id="meet"]`).is(':visible')) {
    return;
}

/* local functions */
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

function uuidv4() {
    return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
        (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
    );
}

/* Google Meet SVG */
const meetButtonSymbol = `🎧`;

/* Description-Text on Hover: Customize this for different languages */
const meetButtonLabel = {
    'en': 'New Google Meet Room',
    'de': 'Öffne Google-Konferenz Raum',
    'fr': 'New Google Meet Room',
    'es': 'New Google Meet Room',
    'it': 'New Google Meet Room',
    'nl': 'New Google Meet Room',
    'pl': 'New Google Meet Room',
    'pt': 'Nova sala do Google Meet',
    'ru': 'Смена оформления'
}[defaultUserLanguage()] || 'New Google Meet Room';

const meetButtonHtml = `<button type="button" data-id="meet" class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button  rcx-button-group__item rcx-css-ll6zd0" data-toolbox="0" title="${meetButtonLabel}">${meetButtonSymbol}</button>`;

const meetButton = $(meetButtonHtml).prependTo(toolbar);

meetButton.on('click', async function () {
    var meetUri = "https://meet.google.com/lookup/r" + uuidv4();
    var chatInput = $('textarea[name="msg"]');
    if (chatInput.length == 1) {
        var keyboardEvent = {
            altKey: false,
            bubbles: true,
            cancelBubble: false,
            cancelable: true,
            charCode: 0,
            code: "Enter",
            composed: true,
            ctrlKey: false,
            currentTarget: document,
            defaultPrevented: false,
            detail: 0,
            eventPhase: 1,
            isComposing: false,
            isTrusted: true,
            key: "Enter",
            keyCode: 13,
            location: 0,
            metaKey: false,
            repeat: false,
            returnValue: true,
            shiftKey: false,
            srcElement: chatInput.get()[0],
            target: chatInput.get()[0],
            type: "keydown",
            which: 13
        };

        chatInput.get()[0].value = `:meet: ${meetUri}`;
        chatInput.change();
        chatInput.focus();
        // chatInput.trigger(keyboardEvent);

        await sleep(500);
    }
    //window.open(meetUri, '_blank');
});

}

/ Interval to check if the icon is there; required for room/chat changes / setInterval(addMeetButton, 500); / LEAVE - gMeetButton /`

anakinpendragon commented 1 year ago

I found the real problem, my rocket chat app was out of date, when i install the new, the svg work.

geekgonecrazy commented 1 year ago

I believe with the latest apps available you can easily start google meet calls. This might should be closed now. I'm not sure that further integration will happen beyond what we now have

deichbewohner commented 1 year ago

6.3.0

/* ENTER - gMeetButton */
function addMeetButton() {
    // preconditions
    const toolbar = $('[data-qa-id=ToolBoxAction-thread]').parent();
    // exit if toolbar isn't visible
    if (!toolbar.is(':visible')) {
        return;
    }

    // exit if toolbar isn't visible
    if ($(`button[data-id="meet"]`).is(':visible')) {
        return;
    }

    /* local functions */
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function uuidv4() {
        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }

    /* Google Meet SVG */
    const meetButtonSymbol = `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 87.5 72">
    <path fill="#00832d" d="M49.5 36l8.53 9.75 11.47 7.33 2-17.02-2-16.64-11.69 6.44z"/>
    <path fill="#0066da" d="M0 51.5V66c0 3.315 2.685 6 6 6h14.5l3-10.96-3-9.54-9.95-3z"/>
    <path fill="#e94235" d="M20.5 0L0 20.5l10.55 3 9.95-3 2.95-9.41z"/>
    <path fill="#2684fc" d="M20.5 20.5H0v31h20.5z"/>
    <path fill="#00ac47" d="M82.6 8.68L69.5 19.42v33.66l13.16 10.79c1.97 1.54 4.85.135 4.85-2.37V11c0-2.535-2.945-3.925-4.91-2.32zM49.5 36v15.5h-29V72h43c3.315 0 6-2.685 6-6V53.08z"/>
    <path fill="#ffba00" d="M63.5 0h-43v20.5h29V36l20-16.57V6c0-3.315-2.685-6-6-6z"/>
</svg>
`;

    /* Description-Text on Hover: Customize this for different languages */
    const meetButtonLabel = 'New Google Meet Room';

    const meetButtonHtml = `<button type="button" data-id="meet" class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button  rcx-button-group__item rcx-css-ll6zd0" data-toolbox="0" title="${meetButtonLabel}">${meetButtonSymbol}</button>`;

    const meetButton = $(meetButtonHtml).prependTo(toolbar);

    meetButton.on('click', async function () {
        var meetUri = "https://meet.google.com/lookup/r" + uuidv4();
        var chatInput = $('textarea[name="msg"]');
        if (chatInput.length == 1) {
            var keyboardEvent = {
                altKey: false,
                bubbles: true,
                cancelBubble: false,
                cancelable: true,
                charCode: 0,
                code: "Enter",
                composed: true,
                ctrlKey: false,
                currentTarget: document,
                defaultPrevented: false,
                detail: 0,
                eventPhase: 1,
                isComposing: false,
                isTrusted: true,
                key: "Enter",
                keyCode: 13,
                location: 0,
                metaKey: false,
                repeat: false,
                returnValue: true,
                shiftKey: false,
                srcElement: chatInput.get()[0],
                target: chatInput.get()[0],
                type: "keydown",
                which: 13
            };

            chatInput.get()[0].value = `:meet: ${meetUri}`;
            chatInput.change();
            chatInput.focus();
            // chatInput.trigger(keyboardEvent);

            await sleep(500);
        }
        //window.open(meetUri, '_blank');
    });
}

/* Interval to check if the icon is there; required for room/chat changes */
setInterval(addMeetButton, 500);
/* LEAVE - gMeetButton */
olsn commented 8 months ago

6.6.0

function isVisible(el) {
  if (typeof el === "string") {
    el = document.querySelector(el);
  }
  if (!el) {
    return false;
  }
  return el.offsetWidth > 0 && el.offsetHeight > 0
}

/* ENTER - gMeetButton */
function addMeetButton() {
    // preconditions
    const toolbar = document.querySelector('[data-qa-id=ToolBoxAction-thread]').parentElement;
    // exit if toolbar isn't visible
    if (!isVisible(toolbar)) {
        return;
    }

    // exit if toolbar is already there
    if (isVisible(`button[data-id="meet"]`)) {
        return;
    }

    /* local functions */
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    function uuidv4() {
        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }

    /* Google Meet SVG */
    const meetButtonSymbol = `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 87.5 72">
    <path fill="#00832d" d="M49.5 36l8.53 9.75 11.47 7.33 2-17.02-2-16.64-11.69 6.44z"/>
    <path fill="#0066da" d="M0 51.5V66c0 3.315 2.685 6 6 6h14.5l3-10.96-3-9.54-9.95-3z"/>
    <path fill="#e94235" d="M20.5 0L0 20.5l10.55 3 9.95-3 2.95-9.41z"/>
    <path fill="#2684fc" d="M20.5 20.5H0v31h20.5z"/>
    <path fill="#00ac47" d="M82.6 8.68L69.5 19.42v33.66l13.16 10.79c1.97 1.54 4.85.135 4.85-2.37V11c0-2.535-2.945-3.925-4.91-2.32zM49.5 36v15.5h-29V72h43c3.315 0 6-2.685 6-6V53.08z"/>
    <path fill="#ffba00" d="M63.5 0h-43v20.5h29V36l20-16.57V6c0-3.315-2.685-6-6-6z"/>
</svg>
`;

    /* Description-Text on Hover: Customize this for different languages */
    const meetButtonLabel = 'New Google Meet Room';

    const meetButtonHtml = `<button type="button" data-id="meet" class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button  rcx-button-group__item rcx-css-ll6zd0" data-toolbox="0" title="${meetButtonLabel}">${meetButtonSymbol}</button>`;

    const meetButton = document.createElement('button');
    meetButton.innerHTML = meetButtonHtml;
    toolbar.insertBefore(meetButton, toolbar.firstChild);

    meetButton.addEventListener('click', async function () {
        var meetUri = "https://meet.google.com/lookup/r" + uuidv4();
        var chatInputs = document.querySelectorAll('textarea[name="msg"]');
        var chatInput = chatInputs[chatInputs.length-1];
        if (chatInput) {
            var keyboardEvent = new KeyboardEvent("keydown", {
                altKey: false,
                bubbles: true,
                cancelBubble: false,
                cancelable: true,
                charCode: 0,
                code: "Enter",
                composed: true,
                ctrlKey: false,
                currentTarget: document,
                defaultPrevented: false,
                detail: 0,
                eventPhase: 1,
                isComposing: false,
                isTrusted: true,
                key: "Enter",
                keyCode: 13,
                location: 0,
                metaKey: false,
                repeat: false,
                returnValue: true,
                shiftKey: false,
                srcElement: chatInput,
                target: chatInput,
                type: "keydown",
                which: 13
            });

            chatInput.value = `:meet: ${meetUri}`;
            chatInput.focus();
            chatInput.dispatchEvent(keyboardEvent);

            await sleep(500);
        }
        //window.open(meetUri, '_blank');
    });
}

/* Interval to check if the icon is there; required for room/chat changes */
setInterval(addMeetButton, 500);
/* LEAVE - gMeetButton */
vladborovtsov commented 3 months ago

@olsn 's solution also compatible to 6.8.2