Skip to content

Instantly share code, notes, and snippets.

@Harry260
Last active October 25, 2021 11:55
Show Gist options
  • Select an option

  • Save Harry260/212489f8f697732dda66038c93b4b6d2 to your computer and use it in GitHub Desktop.

Select an option

Save Harry260/212489f8f697732dda66038c93b4b6d2 to your computer and use it in GitHub Desktop.
USERSCRIPT to add custom Background Image/Video even if host disables it! Version 2!

About

This is a userscript for adding custom background videos and images as google meet background. This works even if the custom background is disabled by the admin (Gsuit feature). This supports .png .jpg/.jpeg .mp4 .gif. If you try to use this by pasting in the webConsole, it wont work!

How to use?

  • Step 1: To use this script, you need to download the extension. You can download this extension from here: Chrome, Firefox
  • Step 2: Click the the Extensions button > Tampermonkey > Create New Userscript..

Image

  • Step 3: Delete everything and paste the code
  • Step 4: Hit CTRL + S to save the file

Image

After you are done with this, Open your Meeting and press CTRL + B to activate the feature. A new button will appear near the buttons below (end call, mute, etc..)

Credits

Made by Harry Tom

Twitter, Github, Portfolio, Email

// ==UserScript==
// @name Custom Background!
// @namespace http://harrytom.ml/
// @version 2.1.0
// @description Add custom Background Image/Video even if host disables it!
// @author Harry Tom
// @match https://meet.google.com/*
// @icon https://i.imgur.com/sEXxzhu.png
// @grant none
// ==/UserScript==
(function() {
window.addEventListener('load', (event) => {
var html = `<div class="gWtGRc" id="addedCheck" style="display:none" jscontroller="nje58b" jsaction="JIbuQc:EBwIVc"><span data-is-tooltip-wrapper="true"><div class="VfPpkd-dgl2Hf-ppHlrf-sM5MNb" data-is-touch-wrapper="true"><button class="VfPpkd-LgbsSe addBack VfPpkd-LgbsSe-OWXEXe-INsAgc VfPpkd-LgbsSe-OWXEXe-dgl2Hf Rj2Mlf OLiIxf PDpWxe P62QJc Pr8ZAd" jscontroller="soHxf" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue; touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc; touchcancel:JMtRjd; focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef" data-idom-class="Rj2Mlf OLiIxf PDpWxe P62QJc Pr8ZAd" jsname="kw8uke" aria-label="Upload a background image" data-tooltip-enabled="true" aria-describedby="tt-upload-background" data-tooltip-y-position="2" data-tooltip-classes="DHN1zf"><div class="VfPpkd-Jh9lGc"></div><div class="VfPpkd-RLmnJb"></div><span jsname="V67aGc" class="VfPpkd-vQzf8d" aria-hidden="true"><div class="uchBpf"><i class="google-material-icons biY3Xc" aria-hidden="true">add_photo_alternate</i></div></span></button></div><div class="EY8ABd-OWXEXe-TAWMXe" role="tooltip" aria-hidden="true" id="tt-upload-background">Upload a background image</div></span><input type="file" jsname="tif8Pe" jsaction="change:E7zRc" accept="image/jpeg, image/png, image/webp, video/mp4, image/gif" style="display: none;"></div>`;
var added = false;
document.addEventListener('keydown', function(event) {
if (event.ctrlKey && event.key === 'b') {
try{
var element = document.getElementById('addedCheck');
if (typeof(element) != 'undefined' && element != null)
{}
else{
document.querySelector('[class="rG0ybd xPh1xb P9KVBf"]').insertAdjacentHTML('beforeend', escapeHTMLPolicy.createHTML(html));
addbutton();
}
}
catch{
errorPop();
}
}
});
function addBack(){
const addBtn = document.querySelector(".addBack");
addBtn.click();
}
function addbutton(){
try {
var newhtml = `<div class="qLBCDc custom-backround"><div class="M5zXed"><div class="VfPpkd-xl07Ob-XxIAqe-OWXEXe-oYxtQd" data-disable-idom="true" data-is-menu-dynamic="true" id="ow288" __is_owner="false"><div ><span data-is-tooltip-wrapper="true" aria-label="More options"><button class="VfPpkd-Bz112c-LgbsSe yHy1rc eT1oJ tWDL4c uaILN" data-disable-idom="true" aria-label="More options" data-tooltip-enabled="true" data-tooltip-id="tt-c68" data-tooltip-x-position="3" data-tooltip-y-position="2" role="button" aria-expanded="false" aria-haspopup="menu" style="--mdc-ripple-fg-size:24px; --mdc-ripple-fg-scale:1.66667; --mdc-ripple-left:8px; --mdc-ripple-top:8px;"><div class="VfPpkd-Bz112c-Jh9lGc"></div><i class="google-material-icons" aria-hidden="true">auto_awesome</i></button><div class="EY8ABd-OWXEXe-TAWMXe" role="tooltip" aria-hidden="true" id="tt-c68">Apply Custom Background</div></span></div><div></div></div><div style="display: none;"></div></div></div>`
var newButton = document.querySelector('[jsname="nzofs"]');
newButton.innerHTML = escapeHTMLPolicy.createHTML(newhtml + newButton.outerHTML);
const backbutton = document.querySelector(".custom-backround");
backbutton.addEventListener('click', function(event) {
addBack();
});
} catch{
errorPop();
}
}
function errorPop(){
var errorHtml = escapeHTMLPolicy.createHTML(`<div class="overlay" style="backdrop-filter:blur(10px);background-color: rgba(0, 0, 0, 0.459);z-index:19999;position: fixed;display: flex;top: 0;left: 0;height: 100vh; width: 100%; align-items: center; justify-content: center;"> <div class="box" style="background-color: white;width: 300px;padding: 20px 35px; border-radius: 10px;box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px;"> <h1 style="font-size: 15px;"> <style>code{background-color: lightgray; border-radius: 5px; padding: 0 3px;}</style> Couldn't Inject the script. Please use <br><code>ctrl</code> + <code>B</code> after joining the meeting. </h1> <button style="background-color: transparent; border: none; cursor: pointer; color: dodgerblue; font-size: 15px; font-weight: 700;" class="close-btn"> Okay </button> </div></div>`);
var errorElemnt = document.createElement("div");
errorElemnt.innerHTML = errorHtml;
document.body.append(errorElemnt);
const closeBtn = document.querySelector(".close-btn");
const overlay = document.querySelector(".overlay");
closeBtn.addEventListener('click', function() {
overlay.remove();
});
}
escapeHTMLPolicy = trustedTypes.createPolicy("forceInner", {
createHTML: (to_escape) => to_escape
});
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment